repo
stringlengths
5
92
file_url
stringlengths
80
287
file_path
stringlengths
5
197
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:37:27
2026-01-04 17:58:21
truncated
bool
2 classes
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/powerpc-aix/syslog.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/powerpc-aix/syslog.rb
# This file is generated by rake. Do not edit. module Syslog module Constants LOG_ALERT = 1 LOG_AUTH = 32 LOG_AUTHPRIV = 80 LOG_CONS = 2 # LOG_CONSOLE not available LOG_CRIT = 2 LOG_CRON = 72 LOG_DAEMON = 24 LOG_DEBUG = 7 LOG_EMERG = 0 LOG_ERR = 3 # LOG_FTP not available LOG_INFO = 6 LOG_KERN = 0 LOG_LOCAL0 = 128 LOG_LOCAL1 = 136 LOG_LOCAL2 = 144 LOG_LOCAL3 = 152 LOG_LOCAL4 = 160 LOG_LOCAL5 = 168 LOG_LOCAL6 = 176 LOG_LOCAL7 = 184 LOG_LPR = 48 LOG_MAIL = 16 LOG_NEWS = 56 # LOG_NODELAY not available LOG_NOTICE = 5 LOG_NOWAIT = 16 # LOG_NTP not available LOG_ODELAY = 4 LOG_PERROR = 32 LOG_PID = 1 # LOG_SECURITY not available LOG_SYSLOG = 40 LOG_USER = 8 LOG_UUCP = 64 LOG_WARNING = 4 end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/powerpc-aix/fcntl.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/powerpc-aix/fcntl.rb
# This file is generated by rake. Do not edit. module Fcntl FD_CLOEXEC = 1 F_DUPFD = 0 F_GETFD = 1 F_GETFL = 3 F_GETLK = 5 F_RDLCK = 1 F_SETFD = 2 F_SETFL = 4 F_SETLK = 6 F_SETLKW = 7 F_UNLCK = 3 F_WRLCK = 2 O_ACCMODE = 3 O_APPEND = 8 O_CREAT = 256 O_EXCL = 1024 O_NDELAY = 32768 O_NOCTTY = 2048 O_NONBLOCK = 4 O_RDONLY = 0 O_RDWR = 2 O_TRUNC = 512 O_WRONLY = 1 end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/powerpc-aix/zlib.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/powerpc-aix/zlib.rb
# This file is generated by rake. Do not edit. ## # The Zlib module contains several classes for compressing and decompressing # streams, and for working with "gzip" files. # # == Classes # # Following are the classes that are most likely to be of interest to the # user: # - Zlib::Inflate # - Zlib::Deflate # - Zlib::GzipReader # - Zlib::GzipWriter # # There are two important base classes for the classes above: Zlib::ZStream # and Zlib::GzipFile. Everything else is an error class. # # == Constants # # Here's a list. # # Zlib::VERSION # The Ruby/zlib version string. # # Zlib::ZLIB_VERSION # The string which represents the version of zlib.h. # # Zlib::BINARY # Zlib::ASCII # Zlib::UNKNOWN # The integers representing data types which Zlib::ZStream#data_type # method returns. # # Zlib::NO_COMPRESSION # Zlib::BEST_SPEED # Zlib::BEST_COMPRESSION # Zlib::DEFAULT_COMPRESSION # The integers representing compression levels which are an argument # for Zlib::Deflate.new, Zlib::Deflate#deflate, and so on. # # Zlib::FILTERED # Zlib::HUFFMAN_ONLY # Zlib::DEFAULT_STRATEGY # The integers representing compression methods which are an argument # for Zlib::Deflate.new and Zlib::Deflate#params. # # Zlib::DEF_MEM_LEVEL # Zlib::MAX_MEM_LEVEL # The integers representing memory levels which are an argument for # Zlib::Deflate.new, Zlib::Deflate#params, and so on. # # Zlib::MAX_WBITS # The default value of windowBits which is an argument for # Zlib::Deflate.new and Zlib::Inflate.new. # # Zlib::NO_FLUSH # Zlib::SYNC_FLUSH # Zlib::FULL_FLUSH # Zlib::FINISH # The integers to control the output of the deflate stream, which are # an argument for Zlib::Deflate#deflate and so on. #-- # These constants are missing! # # Zlib::OS_CODE # Zlib::OS_MSDOS # Zlib::OS_AMIGA # Zlib::OS_VMS # Zlib::OS_UNIX # Zlib::OS_VMCMS # Zlib::OS_ATARI # Zlib::OS_OS2 # Zlib::OS_MACOS # Zlib::OS_ZSYSTEM # Zlib::OS_CPM # Zlib::OS_TOPS20 # Zlib::OS_WIN32 # Zlib::OS_QDOS # Zlib::OS_RISCOS # Zlib::OS_UNKNOWN # The return values of Zlib::GzipFile#os_code method. module Zlib ZLIB_VERSION = "1.2.3" BEST_COMPRESSION = 9 BEST_SPEED = 1 BLOCK = 5 BUF_ERROR = -5 DATA_ERROR = -3 DEFAULT_COMPRESSION = -1 DEFAULT_STRATEGY = 0 DEFLATED = 8 ERRNO = -1 FILTERED = 1 FINISH = 4 FIXED = 4 FULL_FLUSH = 3 HUFFMAN_ONLY = 2 MEM_ERROR = -4 NEED_DICT = 2 NO_COMPRESSION = 0 NO_FLUSH = 0 OK = 0 PARTIAL_FLUSH = 1 RLE = 3 STREAM_END = 1 STREAM_ERROR = -2 SYNC_FLUSH = 2 VERSION_ERROR = -6 # DEF_MEM_LEVEL not available MAX_MEM_LEVEL = 9 MAX_WBITS = 15 OS_MSDOS = 0x00 OS_AMIGA = 0x01 OS_VMS = 0x02 OS_UNIX = 0x03 OS_ATARI = 0x05 OS_OS2 = 0x06 OS_MACOS = 0x07 OS_TOPS20 = 0x0a OS_WIN32 = 0x0b OS_VMCMS = 0x04 OS_ZSYSTEM = 0x08 OS_CPM = 0x09 OS_QDOS = 0x0c OS_RISCOS = 0x0d OS_UNKNOWN = 0xff # OS_CODE not available unless defined? OS_CODE then OS_CODE = OS_UNIX end # from zutil.h unless defined? DEF_MEM_LEVEL then DEF_MEM_LEVEL = MAX_MEM_LEVEL >= 8 ? 8 : MAX_MEM_LEVEL end class Error < StandardError; end class StreamEnd < Error; end class NeedDict < Error; end class StreamError < Error; end class DataError < Error; end class BufError < Error; end class VersionError < Error; end class MemError < Error; end ## # Zlib::ZStream is the abstract class for the stream which handles the # compressed data. The operations are defined in the subclasses: # Zlib::Deflate for compression, and Zlib::Inflate for decompression. # # An instance of Zlib::ZStream has one stream (struct zstream in the source) # and two variable-length buffers which associated to the input (next_in) of # the stream and the output (next_out) of the stream. In this document, # "input buffer" means the buffer for input, and "output buffer" means the # buffer for output. # # Data input into an instance of Zlib::ZStream are temporally stored into # the end of input buffer, and then data in input buffer are processed from # the beginning of the buffer until no more output from the stream is # produced (i.e. until avail_out > 0 after processing). During processing, # output buffer is allocated and expanded automatically to hold all output # data. # # Some particular instance methods consume the data in output buffer and # return them as a String. # # Here is an ascii art for describing above: # # +================ an instance of Zlib::ZStream ================+ # || || # || +--------+ +-------+ +--------+ || # || +--| output |<---------|zstream|<---------| input |<--+ || # || | | buffer | next_out+-------+next_in | buffer | | || # || | +--------+ +--------+ | || # || | | || # +===|======================================================|===+ # | | # v | # "output data" "input data" # # If an error occurs during processing input buffer, an exception which is a # subclass of Zlib::Error is raised. At that time, both input and output # buffer keep their conditions at the time when the error occurs. # # == Method Catalogue # # Many of the methods in this class are fairly low-level and unlikely to be # of interest to users. In fact, users are unlikely to use this class # directly; rather they will be interested in Zlib::Inflate and # Zlib::Deflate. # # The higher level methods are listed below. # # - #total_in # - #total_out # - #data_type # - #adler # - #reset # - #finish # - #finished? # - #close # - #closed? class ZStream < FFI::Struct self.size = 56 layout :next_in, :pointer, 0, :avail_in, :uint, 4, :total_in, :ulong, 8, :next_out, :pointer, 12, :avail_out, :uint, 16, :total_out, :ulong, 20, :msg, :string, 24, :state, :pointer, 28, :zalloc, :pointer, 32, :zfree, :pointer, 36, :opaque, :pointer, 40, :data_type, :int, 44, :adler, :ulong, 48, :reserved, :ulong, 52 #-- # HACK from MRI's zlib.c #++ READY = 0x1 IN_STREAM = 0x2 FINISHED = 0x4 CLOSING = 0x8 UNUSED = 0x10 attr_accessor :flags attr_reader :input attr_reader :output def self.inherited(subclass) subclass.instance_variable_set :@layout, @layout subclass.instance_variable_set :@size, @size end def initialize super self[:avail_in] = 0 self[:avail_out] = 0 self[:next_in] = nil self[:opaque] = nil self[:zalloc] = nil self[:zfree] = nil reset_input @output = nil @flags = 0 @func = nil end def closing? @flags & CLOSING == CLOSING end def detatch_output if @output.nil? then data = '' else data = @output @output = nil self[:avail_out] = 0 self[:next_out] = nil end data end ## # Closes the stream. All operations on the closed stream will raise an # exception. def end unless ready? then warn "attempt to close uninitialized stream; ignored." return nil end if in_stream? then warn "attempt to close unfinished zstream; reset forced" reset end reset_input err = Zlib.send @func_end, pointer Zlib.handle_error err, message @flags = 0 # HACK this may be wrong @output = nil @next_out.free unless @next_out.nil? @next_out = nil nil end alias :close :end def expand_output if @output.nil? then @output = '' @next_out = MemoryPointer.new CHUNK if @next_out.nil? @next_out.write_string "\000" * CHUNK self[:next_out] = @next_out else have = CHUNK - self[:avail_out] @output << @next_out.read_string(have) self[:next_out] = @next_out # Zlib advances self[:next_out] end self[:avail_out] = CHUNK end ## # Finishes the stream and flushes output buffer. See Zlib::Deflate#finish # and Zlib::Inflate#finish for details of this behavior. def finish run '', Zlib::FINISH detatch_output end ## # Returns true if the stream is finished. def finished? @flags & FINISHED == FINISHED end ## # Flushes output buffer and returns all data in that buffer. def flush_next_out detatch_output end def in_stream? @flags & IN_STREAM == IN_STREAM end def input_empty? @input.nil? or @input.empty? end ## # The msg field of the struct def message self[:msg] end def ready @flags |= READY end def ready? @flags & READY == READY end ## # Resets and initializes the stream. All data in both input and output # buffer are discarded. def reset err = Zlib.send @func_reset, pointer Zlib.handle_error err, message @flags = READY reset_input end def reset_input @input = nil end def run(data, flush) if @input.nil? and data.empty? then data_in = MemoryPointer.new 1 data_in.write_string "\000", 1 self[:next_in] = data_in self[:avail_in] = 0 else @input ||= '' @input << data data_in = MemoryPointer.new @input.length data_in.write_string @input, @input.length self[:next_in] = data_in self[:avail_in] = @input.length end expand_output if self[:avail_out] == 0 loop do err = Zlib.send @func_run, pointer, flush available = self[:avail_out] expand_output # HACK does this work when err is set? if err == Zlib::STREAM_END then @flags &= ~IN_STREAM @flags |= FINISHED break end unless err == Zlib::OK then if flush != Zlib::FINISH and err == Zlib::BUF_ERROR and self[:avail_out] > 0 then @flags |= IN_STREAM break end if self[:avail_in] > 0 then @input = self[:next_in].read_string(self[:avail_in]) + @input end Zlib.handle_error err, message end if available > 0 then @flags |= IN_STREAM break end end reset_input if self[:avail_in] > 0 then @input = self[:next_in].read_string self[:avail_in] end ensure data_in.free self[:next_in] = nil end ## # Returns the number of bytes consumed def total_in self[:total_in] end ## # Returns the number bytes processed def total_out self[:total_out] end end set_ffi_lib 'libz' # deflateInit2 is a macro pointing to deflateInit2_ attach_function :deflateInit2_, [ :pointer, # z_streamp strm :int, # int level :int, # int method :int, # int windowBits :int, # int memLevel :int, # int strategy :string, # ZLIB_VERSION :int # (int)sizeof(z_stream) ], :int def self.deflateInit2(stream, level, method, window_bits, mem_level, strategy) deflateInit2_ stream, level, method, window_bits, mem_level, strategy, ZLIB_VERSION, ZStream.size end attach_function :deflate, [:pointer, :int], :int attach_function :deflateEnd, [:pointer], :int attach_function :deflateParams, [:pointer, :int, :int], :int attach_function :deflateReset, [:pointer], :int attach_function :deflateSetDictionary, [:pointer, :string, :uint], :int # inflateInit2 is a macro pointing to inflateInit2_ attach_function :inflateInit2_, [:pointer, :int, :string, :int], :int def self.inflateInit2(stream, window_bits) inflateInit2_ stream, window_bits, ZLIB_VERSION, ZStream.size end attach_function :inflate, [:pointer, :int], :int attach_function :inflateEnd, [:pointer], :int attach_function :inflateReset, [:pointer], :int attach_function :inflateSetDictionary, [:pointer, :string, :uint], :int attach_function :adler32_c, :adler32, [:ulong, :string, :uint], :ulong attach_function :crc32_c, :crc32, [:ulong, :string, :uint], :ulong attach_function :get_crc_table_c, :get_crc_table, [], :pointer attach_function :zError, [:int], :string # Chunk size for inflation and deflation CHUNK = 1024 #-- # HACK from zlib.c #++ GZ_EXTRAFLAG_FAST = 0x4 GZ_EXTRAFLAG_SLOW = 0x2 ## # Zlib::Deflate is the class for compressing data. See Zlib::ZStream for # more information. class Deflate < ZStream ## # Compresses the given +string+. Valid values of level are # <tt>Zlib::NO_COMPRESSION</tt>, <tt>Zlib::BEST_SPEED</tt>, # <tt>Zlib::BEST_COMPRESSION</tt>, <tt>Zlib::DEFAULT_COMPRESSION</tt>, and # an integer from 0 to 9. # # This method is almost equivalent to the following code: # # def deflate(string, level) # z = Zlib::Deflate.new(level) # dst = z.deflate(string, Zlib::FINISH) # z.close # dst # end def self.deflate(data, level = Zlib::DEFAULT_COMPRESSION) deflator = new level zipped = deflator.deflate data, Zlib::FINISH zipped ensure deflator.end end ## # Creates a new deflate stream for compression. See zlib.h for details of # each argument. If an argument is nil, the default value of that argument # is used. def initialize(level = Zlib::DEFAULT_COMPRESSION, window_bits = Zlib::MAX_WBITS, mem_level = Zlib::DEF_MEM_LEVEL, strategy = Zlib::DEFAULT_STRATEGY) level ||= Zlib::DEFAULT_COMPRESSION window_bits ||= Zlib::MAX_WBITS mem_level ||= Zlib::DEF_MEM_LEVEL strategy ||= Zlib::DEFAULT_STRATEGY super() @func_end = :deflateEnd @func_reset = :deflateReset @func_run = :deflate err = Zlib.deflateInit2(pointer, level, Zlib::DEFLATED, window_bits, mem_level, strategy) Zlib.handle_error err, message ready end ## # Same as IO. def <<(data) do_deflate data, Zlib::NO_FLUSH self end ## # Inputs +string+ into the deflate stream and returns the output from the # stream. On calling this method, both the input and the output buffers # of the stream are flushed. If +string+ is nil, this method finishes the # stream, just like Zlib::ZStream#finish. # # The value of +flush+ should be either <tt>Zlib::NO_FLUSH</tt>, # <tt>Zlib::SYNC_FLUSH</tt>, <tt>Zlib::FULL_FLUSH</tt>, or # <tt>Zlib::FINISH</tt>. See zlib.h for details. def deflate(data, flush = Zlib::NO_FLUSH) do_deflate data, flush detatch_output end ## # Performs the deflate operation and leaves the compressed data in the # output buffer def do_deflate(data, flush) if data.nil? then run '', Zlib::FINISH else data = StringValue data if flush != Zlib::NO_FLUSH or not data.empty? then # prevent BUF_ERROR run data, flush end end end ## # Finishes compressing the deflate input stream and returns the output # buffer. def finish run '', Zlib::FINISH detatch_output end ## # This method is equivalent to <tt>deflate('', flush)</tt>. If flush is # omitted, <tt>Zlib::SYNC_FLUSH</tt> is used as flush. This method is # just provided to improve the readability of your Ruby program. def flush(flush = Zlib::SYNC_FLUSH) run '', flush unless flush == Zlib::NO_FLUSH detatch_output end ## # Changes the parameters of the deflate stream. See zlib.h for details. # The output from the stream by changing the params is preserved in output # buffer. def params(level, strategy) err = Zlib.deflateParams pointer, level, strategy raise Zlib::BufError, 'buffer expansion not implemented' if err == Zlib::BUF_ERROR Zlib.handle_error err, message nil end ## # Sets the preset dictionary and returns +dictionary+. This method is # available just only after Zlib::Deflate.new or Zlib::ZStream#reset # method was called. See zlib.h for details. def set_dictionary(dictionary) dict = StringValue dictionary err = Zlib.deflateSetDictionary pointer, dict, dict.length Zlib.handle_error err, message dictionary end end ## # Zlib::GzipFile is an abstract class for handling a gzip formatted # compressed file. The operations are defined in the subclasses, # Zlib::GzipReader for reading, and Zlib::GzipWriter for writing. # # GzipReader should be used by associating an IO, or IO-like, object. class GzipFile SYNC = Zlib::ZStream::UNUSED HEADER_FINISHED = Zlib::ZStream::UNUSED << 1 FOOTER_FINISHED = Zlib::ZStream::UNUSED << 2 FLAG_MULTIPART = 0x2 FLAG_EXTRA = 0x4 FLAG_ORIG_NAME = 0x8 FLAG_COMMENT = 0x10 FLAG_ENCRYPT = 0x20 FLAG_UNKNOWN_MASK = 0xc0 EXTRAFLAG_FAST = 0x4 EXTRAFLAG_SLOW = 0x2 MAGIC1 = 0x1f MAGIC2 = 0x8b METHOD_DEFLATE = 8 ## # Base class of errors that occur when processing GZIP files. class Error < Zlib::Error; end ## # Raised when gzip file footer is not found. class NoFooter < Error; end ## # Raised when the CRC checksum recorded in gzip file footer is not # equivalent to the CRC checksum of the actual uncompressed data. class CRCError < Error; end ## # Raised when the data length recorded in the gzip file footer is not # equivalent to the length of the actual uncompressed data. class LengthError < Error; end ## # Accessor for the underlying ZStream attr_reader :zstream # :nodoc: ## # See Zlib::GzipReader#wrap and Zlib::GzipWriter#wrap. def self.wrap(*args) obj = new(*args) if block_given? then begin yield obj ensure obj.close if obj.zstream.ready? end end end def initialize @comment = nil @crc = 0 @level = nil @mtime = Time.at 0 @orig_name = nil @os_code = Zlib::OS_CODE end ## # Closes the GzipFile object. This method calls close method of the # associated IO object. Returns the associated IO object. def close io = finish io.close if io.respond_to? :close io end ## # Same as IO def closed? @io.nil? end ## # Returns comments recorded in the gzip file header, or nil if the # comment is not present. def comment raise Error, 'closed gzip stream' if @io.nil? @comment.dup end def end return if @zstream.closing? @zstream.flags |= Zlib::ZStream::CLOSING begin end_run ensure @zstream.end end end ## # Closes the GzipFile object. Unlike Zlib::GzipFile#close, this method # never calls the close method of the associated IO object. Returns the # associated IO object. def finish self.end io = @io @io = nil @orig_name = nil @comment = nil io end def finished? @zstream.finished? and @zstream.output.empty? # HACK I think end def footer_finished? @zstream.flags & Zlib::GzipFile::FOOTER_FINISHED == Zlib::GzipFile::FOOTER_FINISHED end def header_finished? @zstream.flags & Zlib::GzipFile::HEADER_FINISHED == Zlib::GzipFile::HEADER_FINISHED end ## # Returns last modification time recorded in the gzip file header. def mtime Time.at @mtime end ## # Returns original filename recorded in the gzip file header, or +nil+ if # original filename is not present. def orig_name raise Error, 'closed gzip stream' if @io.nil? @orig_name.dup end end ## # Zlib::GzipReader is the class for reading a gzipped file. GzipReader # should be used an IO, or -IO-lie, object. # # Zlib::GzipReader.open('hoge.gz') {|gz| # print gz.read # } # # File.open('hoge.gz') do |f| # gz = Zlib::GzipReader.new(f) # print gz.read # gz.close # end # # == Method Catalogue # # The following methods in Zlib::GzipReader are just like their counterparts # in IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an # error was found in the gzip file. # # - #each # - #each_line # - #each_byte # - #gets # - #getc # - #lineno # - #lineno= # - #read # - #readchar # - #readline # - #readlines # - #ungetc # # Be careful of the footer of the gzip file. A gzip file has the checksum of # pre-compressed data in its footer. GzipReader checks all uncompressed data # against that checksum at the following cases, and if it fails, raises # <tt>Zlib::GzipFile::NoFooter</tt>, <tt>Zlib::GzipFile::CRCError</tt>, or # <tt>Zlib::GzipFile::LengthError</tt> exception. # # - When an reading request is received beyond the end of file (the end of # compressed data). That is, when Zlib::GzipReader#read, # Zlib::GzipReader#gets, or some other methods for reading returns nil. # - When Zlib::GzipFile#close method is called after the object reaches the # end of file. # - When Zlib::GzipReader#unused method is called after the object reaches # the end of file. # # The rest of the methods are adequately described in their own # documentation. class GzipReader < GzipFile # HACK use a buffer class ## # Creates a GzipReader object associated with +io+. The GzipReader object # reads gzipped data from +io+, and parses/decompresses them. At least, # +io+ must have a +read+ method that behaves same as the +read+ method in # IO class. # # If the gzip file header is incorrect, raises an Zlib::GzipFile::Error # exception. def initialize(io) @io = io @zstream = Zlib::Inflate.new -Zlib::MAX_WBITS @buffer = '' super() read_header end def check_footer @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED footer = @zstream.input.slice! 0, 8 rest = @io.read 8 - footer.length footer << rest if rest raise NoFooter, 'footer is not found' unless footer.length == 8 crc, length = footer.unpack 'VV' @zstream[:total_in] += 8 # to rewind correctly raise CRCError, 'invalid compressed data -- crc error' unless @crc == crc raise LengthError, 'invalid compressed data -- length error' unless length == @zstream.total_out end def end_run check_footer if @zstream.finished? and not footer_finished? end def eof? @zstream.finished? and @zstream.input_empty? end def pos @zstream[:total_out] - @buffer.length end ## # See Zlib::GzipReader documentation for a description. def read(length = nil) data = @buffer while chunk = @io.read(CHUNK) do inflated = @zstream.inflate(chunk) @crc = Zlib.crc32 inflated, @crc data << inflated break if length and data.length > length end if length then @buffer = data.slice! length..-1 else @buffer = '' end check_footer if @zstream.finished? and not footer_finished? data rescue Zlib::Error => e raise GzipFile::Error, e.message end def read_header header = @io.read 10 raise Error, 'not in gzip format' unless header.length == 10 magic1, magic2, method, flags, @mtime, extra_flags, @os_code = header.unpack 'CCCCVCC' unless magic1 == Zlib::GzipFile::MAGIC1 and magic2 == Zlib::GzipFile::MAGIC2 then raise Error, 'not in gzip format' end unless method == Zlib::GzipFile::METHOD_DEFLATE then raise Error, "unsupported compression method #{method}" end if flags & Zlib::GzipFile::FLAG_MULTIPART == Zlib::GzipFile::FLAG_MULTIPART then raise Error, 'multi-part gzip file is not supported' end if flags & Zlib::GzipFile::FLAG_ENCRYPT == Zlib::GzipFile::FLAG_ENCRYPT then raise Error, 'encrypted gzip file is not supported' end if flags & Zlib::GzipFile::FLAG_UNKNOWN_MASK == Zlib::GzipFile::FLAG_UNKNOWN_MASK then raise Error, "unknown flags 0x#{flags.to_s 16}" end if extra_flags & Zlib::GzipFile::EXTRAFLAG_FAST == Zlib::GzipFile::EXTRAFLAG_FAST then @level = Zlib::BEST_SPEED elsif extra_flags & Zlib::GzipFile::EXTRAFLAG_SLOW == Zlib::GzipFile::EXTRAFLAG_SLOW then @level = Zlib::BEST_COMPRESSION else @level = Zlib::DEFAULT_COMPRESSION end if flags & Zlib::GzipFile::FLAG_EXTRA == Zlib::GzipFile::FLAG_EXTRA then length = @io.read 2 raise Zlib::GzipFile::Error, 'unexpected end of file' if length.nil? or length.length != 2 length, = length.unpack 'v' extra = @io.read length + 2 raise Zlib::GzipFile::Error, 'unexpected end of file' if extra.nil? or extra.length != length + 2 end if flags & Zlib::GzipFile::FLAG_ORIG_NAME == Zlib::GzipFile::FLAG_ORIG_NAME then @orig_name = '' c = @io.getc until c == 0 do @orig_name << c.chr c = @io.getc end end if flags & Zlib::GzipFile::FLAG_COMMENT == Zlib::GzipFile::FLAG_COMMENT then @comment = '' c = @io.getc until c == 0 do @comment << c.chr c = @io.getc end end end end ## # Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should # be used with an instance of IO, or IO-like, object. # # For example: # # Zlib::GzipWriter.open('hoge.gz') do |gz| # gz.write 'jugemu jugemu gokou no surikire...' # end # # File.open('hoge.gz', 'w') do |f| # gz = Zlib::GzipWriter.new(f) # gz.write 'jugemu jugemu gokou no surikire...' # gz.close # end # # NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close # GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter # will be not able to write the gzip footer and will generate a broken gzip # file. class GzipWriter < GzipFile # HACK use a buffer class ## # Set the comment attr_writer :comment ## # Set the original name attr_writer :orig_name ## # Creates a GzipWriter object associated with +io+. +level+ and +strategy+ # should be the same as the arguments of Zlib::Deflate.new. The # GzipWriter object writes gzipped data to +io+. At least, +io+ must # respond to the +write+ method that behaves same as write method in IO # class. def initialize(io, level = Zlib::DEFAULT_COMPRESSION, strategy = Zlib::DEFAULT_STRATEGY) @io = io @zstream = Zlib::Deflate.new level, -Zlib::MAX_WBITS, Zlib::DEF_MEM_LEVEL, strategy @buffer = '' super() end def end_run make_header unless header_finished? @zstream.run '', Zlib::FINISH write_raw make_footer nil end ## # Flushes all the internal buffers of the GzipWriter object. The meaning # of +flush+ is same as in Zlib::Deflate#deflate. # <tt>Zlib::SYNC_FLUSH</tt> is used if +flush+ is omitted. It is no use # giving flush <tt>Zlib::NO_FLUSH</tt>. def flush true end ## # Writes out a gzip header def make_header flags = 0 extra_flags = 0 flags |= Zlib::GzipFile::FLAG_ORIG_NAME if @orig_name flags |= Zlib::GzipFile::FLAG_COMMENT if @comment extra_flags |= Zlib::GzipFile::EXTRAFLAG_FAST if @level == Zlib::BEST_SPEED extra_flags |= Zlib::GzipFile::EXTRAFLAG_SLOW if @level == Zlib::BEST_COMPRESSION header = [ Zlib::GzipFile::MAGIC1, # byte 0 Zlib::GzipFile::MAGIC2, # byte 1 Zlib::GzipFile::METHOD_DEFLATE, # byte 2 flags, # byte 3 @mtime.to_i, # bytes 4-7 extra_flags, # byte 8 @os_code # byte 9 ].pack 'CCCCVCC' @io.write header @io.write "#{@orig_name}\0" if @orig_name @io.write "#{@comment}\0" if @comment @zstream.flags |= Zlib::GzipFile::HEADER_FINISHED end ## # Writes out a gzip footer def make_footer footer = [ @crc, # bytes 0-3 @zstream.total_in, # bytes 4-7 ].pack 'VV' @io.write footer @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED end ## # Sets the modification time of this file def mtime=(time) if header_finished? then raise Zlib::GzipFile::Error, 'header is already written' end @mtime = Integer time end def sync? @zstream.flags & Zlib::GzipFile::SYNC == Zlib::GzipFile::SYNC end ## # Same as IO. def write(data) make_header unless header_finished? data = String data if data.length > 0 or sync? then @crc = Zlib.crc32_c @crc, data, data.length flush = sync? ? Zlib::SYNC_FLUSH : Zlib::NO_FLUSH @zstream.run data, flush end write_raw end ## # Same as IO. alias << write def write_raw data = @zstream.detatch_output unless data.empty? then @io.write data @io.flush if sync? and io.respond_to :flush end end end ## # Zlib:Inflate is the class for decompressing compressed data. Unlike # Zlib::Deflate, an instance of this class is not able to duplicate (clone, # dup) itself. class Inflate < ZStream ## # Decompresses +string+. Raises a Zlib::NeedDict exception if a preset # dictionary is needed for decompression. # # This method is almost equivalent to the following code: # # def inflate(string) # zstream = Zlib::Inflate.new # buf = zstream.inflate(string) # zstream.finish # zstream.close # buf # end def self.inflate(data) inflator = new unzipped = inflator.inflate data unzipped ensure inflator.end end ## # Creates a new inflate stream for decompression. See zlib.h for details # of the argument. If +window_bits+ is +nil+, the default value is used. def initialize(window_bits = Zlib::MAX_WBITS) super() @func_end = :inflateEnd @func_reset = :inflateReset @func_run = :inflate err = Zlib.inflateInit2 pointer, window_bits Zlib.handle_error err, message # HACK ready end ## # Inputs +string+ into the inflate stream just like Zlib::Inflate#inflate, # but returns the Zlib::Inflate object itself. The output from the stream # is preserved in output buffer. def <<(string) string = StringValue string unless string.nil? if finished? then unless string.nil? then @input ||= '' @input << string end else run string, Zlib::SYNC_FLUSH end end ## # Inputs +string+ into the inflate stream and returns the output from the # stream. Calling this method, both the input and the output buffer of # the stream are flushed. If string is +nil+, this method finishes the
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
true
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/powerpc-aix/sysconf.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/powerpc-aix/sysconf.rb
# This file is generated by rake. Do not edit. module Platform;end module Platform::Sysconf SC_2_CHAR_TERM = 54 SC_2_C_BIND = 51 SC_2_C_DEV = 32 SC_2_FORT_DEV = 33 SC_2_FORT_RUN = 34 SC_2_LOCALEDEF = 35 SC_2_PBS = 132 SC_2_PBS_ACCOUNTING = 133 SC_2_PBS_CHECKPOINT = 134 SC_2_PBS_LOCATE = 135 SC_2_PBS_MESSAGE = 136 SC_2_PBS_TRACK = 137 SC_2_SW_DEV = 36 SC_2_UPE = 53 SC_2_VERSION = 31 SC_ADVISORY_INFO = 130 SC_AIO_LISTIO_MAX = 75 SC_AIO_MAX = 76 SC_AIO_PRIO_DELTA_MAX = 77 SC_ARG_MAX = 0 SC_ASYNCHRONOUS_IO = 78 SC_ATEXIT_MAX = 47 SC_BARRIERS = 138 SC_BC_BASE_MAX = 23 SC_BC_DIM_MAX = 24 SC_BC_SCALE_MAX = 25 SC_BC_STRING_MAX = 26 SC_CHILD_MAX = 1 SC_CLK_TCK = 2 SC_CLOCK_SELECTION = 139 SC_COLL_WEIGHTS_MAX = 50 SC_CPUTIME = 140 SC_DELAYTIMER_MAX = 79 SC_EXPR_NEST_MAX = 28 SC_FILE_LOCKING = 131 SC_FSYNC = 80 SC_GETGR_R_SIZE_MAX = 81 SC_GETPW_R_SIZE_MAX = 82 SC_HOST_NAME_MAX = 126 SC_IOV_MAX = 58 SC_IPV6 = 154 SC_JOB_CONTROL = 7 SC_LINE_MAX = 29 SC_LOGIN_NAME_MAX = 83 SC_MAPPED_FILES = 84 SC_MEMLOCK = 85 SC_MEMLOCK_RANGE = 86 SC_MEMORY_PROTECTION = 87 SC_MESSAGE_PASSING = 88 SC_MONOTONIC_CLOCK = 141 SC_MQ_OPEN_MAX = 89 SC_MQ_PRIO_MAX = 90 SC_NGROUPS_MAX = 3 SC_NPROCESSORS_CONF = 71 SC_NPROCESSORS_ONLN = 72 SC_OPEN_MAX = 4 SC_PAGESIZE = 48 SC_PAGE_SIZE = 48 SC_PASS_MAX = 45 SC_PRIORITIZED_IO = 91 SC_PRIORITY_SCHEDULING = 92 SC_RAW_SOCKETS = 155 SC_READER_WRITER_LOCKS = 142 SC_REALTIME_SIGNALS = 93 SC_REGEXP = 127 SC_RE_DUP_MAX = 30 SC_RTSIG_MAX = 94 SC_SAVED_IDS = 8 SC_SEMAPHORES = 95 SC_SEM_NSEMS_MAX = 96 SC_SEM_VALUE_MAX = 97 SC_SHARED_MEMORY_OBJECTS = 98 SC_SHELL = 128 SC_SIGQUEUE_MAX = 99 SC_SPAWN = 143 SC_SPIN_LOCKS = 144 SC_SPORADIC_SERVER = 145 SC_SS_REPL_MAX = 156 SC_STREAM_MAX = 5 SC_SYMLOOP_MAX = 129 SC_SYNCHRONIZED_IO = 100 SC_THREADS = 60 SC_THREAD_ATTR_STACKADDR = 61 SC_THREAD_ATTR_STACKSIZE = 62 SC_THREAD_CPUTIME = 146 SC_THREAD_DESTRUCTOR_ITERATIONS = 101 SC_THREAD_KEYS_MAX = 68 SC_THREAD_PRIORITY_SCHEDULING = 64 SC_THREAD_PRIO_INHERIT = 65 SC_THREAD_PRIO_PROTECT = 66 SC_THREAD_PROCESS_SHARED = 67 SC_THREAD_SAFE_FUNCTIONS = 59 SC_THREAD_SPORADIC_SERVER = 147 SC_THREAD_STACK_MIN = 69 SC_THREAD_THREADS_MAX = 70 SC_TIMEOUTS = 148 SC_TIMERS = 102 SC_TIMER_MAX = 103 SC_TRACE = 149 SC_TRACE_EVENT_FILTER = 150 SC_TRACE_EVENT_NAME_MAX = 157 SC_TRACE_INHERIT = 151 SC_TRACE_LOG = 152 SC_TRACE_NAME_MAX = 158 SC_TRACE_SYS_MAX = 159 SC_TRACE_USER_EVENT_MAX = 160 SC_TTY_NAME_MAX = 104 SC_TYPED_MEMORY_OBJECTS = 153 SC_TZNAME_MAX = 6 SC_V6_ILP32_OFF32 = 121 SC_V6_ILP32_OFFBIG = 122 SC_V6_LP64_OFF64 = 123 SC_V6_LPBIG_OFFBIG = 124 SC_VERSION = 9 SC_XBS5_ILP32_OFF32 = 105 SC_XBS5_ILP32_OFFBIG = 106 SC_XBS5_LP64_OFF64 = 107 SC_XBS5_LPBIG_OFFBIG = 108 SC_XOPEN_CRYPT = 56 SC_XOPEN_ENH_I18N = 57 SC_XOPEN_LEGACY = 112 SC_XOPEN_REALTIME = 110 SC_XOPEN_REALTIME_THREADS = 111 SC_XOPEN_SHM = 55 SC_XOPEN_STREAMS = 125 SC_XOPEN_UNIX = 73 SC_XOPEN_VERSION = 46 SC_XOPEN_XCU_VERSION = 109 end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-darwin/errno.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-darwin/errno.rb
# This file is generated by rake. Do not edit. module Platform; end module Platform::Errno E2BIG = 7 EACCES = 13 EADDRINUSE = 48 EADDRNOTAVAIL = 49 EAFNOSUPPORT = 47 EAGAIN = 35 EALREADY = 37 EBADF = 9 EBUSY = 16 ECHILD = 10 ECONNABORTED = 53 ECONNREFUSED = 61 ECONNRESET = 54 EDEADLK = 11 EDESTADDRREQ = 39 EEXIST = 17 EFAULT = 14 EFBIG = 27 EHOSTDOWN = 64 EHOSTUNREACH = 65 EINPROGRESS = 36 EINTR = 4 EINVAL = 22 EIO = 5 EISCONN = 56 EISDIR = 21 ELOOP = 62 EMFILE = 24 EMLINK = 31 EMSGSIZE = 40 ENAMETOOLONG = 63 ENETDOWN = 50 ENETRESET = 52 ENETUNREACH = 51 ENFILE = 23 ENOBUFS = 55 ENODEV = 19 ENOENT = 2 ENOEXEC = 8 ENOMEM = 12 ENOPROTOOPT = 42 ENOSPC = 28 ENOTCONN = 57 ENOTDIR = 20 ENOTEMPTY = 66 ENOTSOCK = 38 ENOTTY = 25 ENXIO = 6 EOPNOTSUPP = 102 EPERM = 1 EPIPE = 32 EPROTONOSUPPORT = 43 EPROTOTYPE = 41 EROFS = 30 ESPIPE = 29 ESRCH = 3 ETIMEDOUT = 60 ETXTBSY = 26 EWOULDBLOCK = 35 EXDEV = 18 end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-darwin/socket.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-darwin/socket.rb
# This file is generated by rake. Do not edit. module Platform; end module Platform::Socket AF_APPLETALK = 16 # AF_ATM not available # AF_AX25 not available AF_CCITT = 10 AF_CHAOS = 5 AF_CNT = 21 AF_COIP = 20 AF_DATAKIT = 9 AF_DECnet = 12 AF_DLI = 13 AF_E164 = 28 AF_ECMA = 8 AF_HYLINK = 15 AF_IMPLINK = 3 AF_INET = 2 AF_INET6 = 30 AF_IPX = 23 AF_ISDN = 28 AF_ISO = 7 AF_LAT = 14 AF_LINK = 18 AF_LOCAL = 1 AF_MAX = 37 AF_NATM = 31 AF_NDRV = 27 AF_NETBIOS = 33 # AF_NETGRAPH not available AF_NS = 6 AF_OSI = 7 AF_PPP = 34 AF_PUP = 4 AF_ROUTE = 17 AF_SIP = 24 AF_SNA = 11 AF_SYSTEM = 32 AF_UNIX = 1 AF_UNSPEC = 0 NI_DGRAM = 16 NI_FQDN_FLAG_VALIDTTL = 256 NI_MAXHOST = 1025 NI_MAXSERV = 32 NI_NAMEREQD = 4 NI_NODEADDR_FLAG_ALL = 512 NI_NODEADDR_FLAG_ANYCAST = 16384 NI_NODEADDR_FLAG_COMPAT = 1024 NI_NODEADDR_FLAG_GLOBAL = 8192 NI_NODEADDR_FLAG_LINKLOCAL = 2048 NI_NODEADDR_FLAG_SITELOCAL = 4096 NI_NODEADDR_FLAG_TRUNCATE = 256 NI_NOFQDN = 1 NI_NUMERICHOST = 2 NI_NUMERICSERV = 8 NI_QTYPE_DNSNAME = 2 NI_QTYPE_FQDN = 2 NI_QTYPE_IPV4ADDR = 4 NI_QTYPE_NODEADDR = 3 NI_QTYPE_NOOP = 0 NI_QTYPE_SUPTYPES = 1 NI_SUPTYPE_FLAG_COMPRESS = 256 NI_WITHSCOPEID = 32 PF_APPLETALK = 16 # PF_ATM not available PF_CCITT = 10 PF_CHAOS = 5 PF_CNT = 21 PF_COIP = 20 PF_DATAKIT = 9 PF_DECnet = 12 PF_DLI = 13 PF_ECMA = 8 PF_HYLINK = 15 PF_IMPLINK = 3 PF_INET = 2 PF_INET6 = 30 PF_IPX = 23 PF_ISDN = 28 PF_ISO = 7 PF_KEY = 29 PF_LAT = 14 PF_LINK = 18 PF_LOCAL = 1 PF_MAX = 37 PF_NATM = 31 PF_NDRV = 27 PF_NETBIOS = 33 # PF_NETGRAPH not available PF_NS = 6 PF_OSI = 7 PF_PIP = 25 PF_PPP = 34 PF_PUP = 4 PF_ROUTE = 17 PF_RTIP = 22 PF_SIP = 24 PF_SNA = 11 PF_SYSTEM = 32 PF_UNIX = 1 PF_UNSPEC = 0 PF_XTP = 19 SOCK_DGRAM = 2 SOCK_MAXADDRLEN = 255 SOCK_RAW = 3 SOCK_RDM = 4 SOCK_SEQPACKET = 5 SOCK_STREAM = 1 SO_ACCEPTCONN = 2 # SO_ACCEPTFILTER not available # SO_ATTACH_FILTER not available # SO_BINDTODEVICE not available SO_BROADCAST = 32 SO_DEBUG = 1 # SO_DETACH_FILTER not available SO_DONTROUTE = 16 SO_DONTTRUNC = 8192 SO_ERROR = 4103 SO_KEEPALIVE = 8 SO_LABEL = 4112 SO_LINGER = 128 SO_NKE = 4129 SO_NOADDRERR = 4131 SO_NOSIGPIPE = 4130 # SO_NO_CHECK not available SO_NREAD = 4128 SO_NWRITE = 4132 SO_OOBINLINE = 256 # SO_PASSCRED not available # SO_PEERCRED not available SO_PEERLABEL = 4113 # SO_PEERNAME not available # SO_PRIORITY not available SO_RCVBUF = 4098 SO_RCVLOWAT = 4100 SO_RCVTIMEO = 4102 SO_REUSEADDR = 4 SO_REUSEPORT = 512 SO_REUSESHAREUID = 4133 # SO_SECURITY_AUTHENTICATION not available # SO_SECURITY_ENCRYPTION_NETWORK not available # SO_SECURITY_ENCRYPTION_TRANSPORT not available SO_SNDBUF = 4097 SO_SNDLOWAT = 4099 SO_SNDTIMEO = 4101 SO_TIMESTAMP = 1024 SO_TYPE = 4104 SO_USELOOPBACK = 64 SO_WANTMORE = 16384 SO_WANTOOBFLAG = 32768 pseudo_AF_HDRCMPLT = 35 pseudo_AF_KEY = 29 pseudo_AF_PIP = 25 pseudo_AF_RTIP = 22 pseudo_AF_XTP = 19 end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-darwin/stat.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-darwin/stat.rb
# This file is generated by rake. Do not edit. module Platform module Stat class Stat < FFI::Struct self.size = 144 layout :st_dev, :dev_t, 0, :st_ino, :ino_t, 8, :st_nlink, :nlink_t, 6, :st_mode, :mode_t, 4, :st_uid, :uid_t, 16, :st_gid, :gid_t, 20, :st_size, :off_t, 96, :st_blocks, :blkcnt_t, 104, :st_atime, :time_t, 32, :st_mtime, :time_t, 48, :st_ctime, :time_t, 64 end module Constants S_IEXEC = 0x40 S_IREAD = 0x100 S_IRGRP = 0x20 S_IROTH = 0x4 S_IRUSR = 0x100 S_IRWXG = 0x38 S_IRWXO = 0x7 S_IRWXU = 0x1c0 S_ISGID = 0x400 S_ISUID = 0x800 S_IWGRP = 0x10 S_IWOTH = 0x2 S_IWRITE = 0x80 S_IWUSR = 0x80 S_IXGRP = 0x8 S_IXOTH = 0x1 S_IXUSR = 0x40 end include Constants end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-darwin/etc.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-darwin/etc.rb
# This file is generated by rake. Do not edit. module Platform; end module Platform::Etc class Passwd < FFI::Struct self.size = 72 layout :pw_name, :string, 0, :pw_passwd, :string, 8, :pw_uid, :uint, 16, :pw_gid, :uint, 20, :pw_dir, :string, 48, :pw_shell, :string, 56 end class Group < FFI::Struct self.size = 32 layout :gr_name, :string, 0, :gr_gid, :uint, 16 end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-darwin/syslog.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-darwin/syslog.rb
# This file is generated by rake. Do not edit. module Syslog module Constants LOG_ALERT = 1 LOG_AUTH = 32 LOG_AUTHPRIV = 80 LOG_CONS = 2 # LOG_CONSOLE not available LOG_CRIT = 2 LOG_CRON = 72 LOG_DAEMON = 24 LOG_DEBUG = 7 LOG_EMERG = 0 LOG_ERR = 3 LOG_FTP = 88 LOG_INFO = 6 LOG_KERN = 0 LOG_LOCAL0 = 128 LOG_LOCAL1 = 136 LOG_LOCAL2 = 144 LOG_LOCAL3 = 152 LOG_LOCAL4 = 160 LOG_LOCAL5 = 168 LOG_LOCAL6 = 176 LOG_LOCAL7 = 184 LOG_LPR = 48 LOG_MAIL = 16 LOG_NEWS = 56 # LOG_NODELAY not available LOG_NOTICE = 5 LOG_NOWAIT = 16 # LOG_NTP not available LOG_ODELAY = 4 LOG_PERROR = 32 LOG_PID = 1 # LOG_SECURITY not available LOG_SYSLOG = 40 LOG_USER = 8 LOG_UUCP = 64 LOG_WARNING = 4 end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-darwin/fcntl.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-darwin/fcntl.rb
# This file is generated by rake. Do not edit. module Fcntl FD_CLOEXEC = 1 F_DUPFD = 0 F_GETFD = 1 F_GETFL = 3 F_GETLK = 7 F_RDLCK = 1 F_SETFD = 2 F_SETFL = 4 F_SETLK = 8 F_SETLKW = 9 F_UNLCK = 2 F_WRLCK = 3 O_ACCMODE = 3 O_APPEND = 8 O_CREAT = 512 O_EXCL = 2048 O_NDELAY = 4 O_NOCTTY = 131072 O_NONBLOCK = 4 O_RDONLY = 0 O_RDWR = 2 O_TRUNC = 1024 O_WRONLY = 1 end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-darwin/zlib.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-darwin/zlib.rb
# This file is generated by rake. Do not edit. ## # The Zlib module contains several classes for compressing and decompressing # streams, and for working with "gzip" files. # # == Classes # # Following are the classes that are most likely to be of interest to the # user: # - Zlib::Inflate # - Zlib::Deflate # - Zlib::GzipReader # - Zlib::GzipWriter # # There are two important base classes for the classes above: Zlib::ZStream # and Zlib::GzipFile. Everything else is an error class. # # == Constants # # Here's a list. # # Zlib::VERSION # The Ruby/zlib version string. # # Zlib::ZLIB_VERSION # The string which represents the version of zlib.h. # # Zlib::BINARY # Zlib::ASCII # Zlib::UNKNOWN # The integers representing data types which Zlib::ZStream#data_type # method returns. # # Zlib::NO_COMPRESSION # Zlib::BEST_SPEED # Zlib::BEST_COMPRESSION # Zlib::DEFAULT_COMPRESSION # The integers representing compression levels which are an argument # for Zlib::Deflate.new, Zlib::Deflate#deflate, and so on. # # Zlib::FILTERED # Zlib::HUFFMAN_ONLY # Zlib::DEFAULT_STRATEGY # The integers representing compression methods which are an argument # for Zlib::Deflate.new and Zlib::Deflate#params. # # Zlib::DEF_MEM_LEVEL # Zlib::MAX_MEM_LEVEL # The integers representing memory levels which are an argument for # Zlib::Deflate.new, Zlib::Deflate#params, and so on. # # Zlib::MAX_WBITS # The default value of windowBits which is an argument for # Zlib::Deflate.new and Zlib::Inflate.new. # # Zlib::NO_FLUSH # Zlib::SYNC_FLUSH # Zlib::FULL_FLUSH # Zlib::FINISH # The integers to control the output of the deflate stream, which are # an argument for Zlib::Deflate#deflate and so on. #-- # These constants are missing! # # Zlib::OS_CODE # Zlib::OS_MSDOS # Zlib::OS_AMIGA # Zlib::OS_VMS # Zlib::OS_UNIX # Zlib::OS_VMCMS # Zlib::OS_ATARI # Zlib::OS_OS2 # Zlib::OS_MACOS # Zlib::OS_ZSYSTEM # Zlib::OS_CPM # Zlib::OS_TOPS20 # Zlib::OS_WIN32 # Zlib::OS_QDOS # Zlib::OS_RISCOS # Zlib::OS_UNKNOWN # The return values of Zlib::GzipFile#os_code method. module Zlib ZLIB_VERSION = "1.2.3" BEST_COMPRESSION = 9 BEST_SPEED = 1 BLOCK = 5 BUF_ERROR = -5 DATA_ERROR = -3 DEFAULT_COMPRESSION = -1 DEFAULT_STRATEGY = 0 DEFLATED = 8 ERRNO = -1 FILTERED = 1 FINISH = 4 FIXED = 4 FULL_FLUSH = 3 HUFFMAN_ONLY = 2 MEM_ERROR = -4 NEED_DICT = 2 NO_COMPRESSION = 0 NO_FLUSH = 0 OK = 0 PARTIAL_FLUSH = 1 RLE = 3 STREAM_END = 1 STREAM_ERROR = -2 SYNC_FLUSH = 2 VERSION_ERROR = -6 # DEF_MEM_LEVEL not available MAX_MEM_LEVEL = 9 MAX_WBITS = 15 OS_MSDOS = 0x00 OS_AMIGA = 0x01 OS_VMS = 0x02 OS_UNIX = 0x03 OS_ATARI = 0x05 OS_OS2 = 0x06 OS_MACOS = 0x07 OS_TOPS20 = 0x0a OS_WIN32 = 0x0b OS_VMCMS = 0x04 OS_ZSYSTEM = 0x08 OS_CPM = 0x09 OS_QDOS = 0x0c OS_RISCOS = 0x0d OS_UNKNOWN = 0xff # OS_CODE not available unless defined? OS_CODE then OS_CODE = OS_UNIX end # from zutil.h unless defined? DEF_MEM_LEVEL then DEF_MEM_LEVEL = MAX_MEM_LEVEL >= 8 ? 8 : MAX_MEM_LEVEL end class Error < StandardError; end class StreamEnd < Error; end class NeedDict < Error; end class StreamError < Error; end class DataError < Error; end class BufError < Error; end class VersionError < Error; end class MemError < Error; end ## # Zlib::ZStream is the abstract class for the stream which handles the # compressed data. The operations are defined in the subclasses: # Zlib::Deflate for compression, and Zlib::Inflate for decompression. # # An instance of Zlib::ZStream has one stream (struct zstream in the source) # and two variable-length buffers which associated to the input (next_in) of # the stream and the output (next_out) of the stream. In this document, # "input buffer" means the buffer for input, and "output buffer" means the # buffer for output. # # Data input into an instance of Zlib::ZStream are temporally stored into # the end of input buffer, and then data in input buffer are processed from # the beginning of the buffer until no more output from the stream is # produced (i.e. until avail_out > 0 after processing). During processing, # output buffer is allocated and expanded automatically to hold all output # data. # # Some particular instance methods consume the data in output buffer and # return them as a String. # # Here is an ascii art for describing above: # # +================ an instance of Zlib::ZStream ================+ # || || # || +--------+ +-------+ +--------+ || # || +--| output |<---------|zstream|<---------| input |<--+ || # || | | buffer | next_out+-------+next_in | buffer | | || # || | +--------+ +--------+ | || # || | | || # +===|======================================================|===+ # | | # v | # "output data" "input data" # # If an error occurs during processing input buffer, an exception which is a # subclass of Zlib::Error is raised. At that time, both input and output # buffer keep their conditions at the time when the error occurs. # # == Method Catalogue # # Many of the methods in this class are fairly low-level and unlikely to be # of interest to users. In fact, users are unlikely to use this class # directly; rather they will be interested in Zlib::Inflate and # Zlib::Deflate. # # The higher level methods are listed below. # # - #total_in # - #total_out # - #data_type # - #adler # - #reset # - #finish # - #finished? # - #close # - #closed? class ZStream < FFI::Struct self.size = 112 layout :next_in, :pointer, 0, :avail_in, :uint, 8, :total_in, :ulong, 16, :next_out, :pointer, 24, :avail_out, :uint, 32, :total_out, :ulong, 40, :msg, :string, 48, :state, :pointer, 56, :zalloc, :pointer, 64, :zfree, :pointer, 72, :opaque, :pointer, 80, :data_type, :int, 88, :adler, :ulong, 96, :reserved, :ulong, 104 #-- # HACK from MRI's zlib.c #++ READY = 0x1 IN_STREAM = 0x2 FINISHED = 0x4 CLOSING = 0x8 UNUSED = 0x10 attr_accessor :flags attr_reader :input attr_reader :output def self.inherited(subclass) subclass.instance_variable_set :@layout, @layout subclass.instance_variable_set :@size, @size end def initialize super self[:avail_in] = 0 self[:avail_out] = 0 self[:next_in] = nil self[:opaque] = nil self[:zalloc] = nil self[:zfree] = nil reset_input @output = nil @flags = 0 @func = nil end def closing? @flags & CLOSING == CLOSING end def detatch_output if @output.nil? then data = '' else data = @output @output = nil self[:avail_out] = 0 self[:next_out] = nil end data end ## # Closes the stream. All operations on the closed stream will raise an # exception. def end unless ready? then warn "attempt to close uninitialized stream; ignored." return nil end if in_stream? then warn "attempt to close unfinished zstream; reset forced" reset end reset_input err = Zlib.send @func_end, pointer Zlib.handle_error err, message @flags = 0 # HACK this may be wrong @output = nil @next_out.free unless @next_out.nil? @next_out = nil nil end alias :close :end def expand_output if @output.nil? then @output = '' @next_out = MemoryPointer.new CHUNK if @next_out.nil? @next_out.write_string "\000" * CHUNK self[:next_out] = @next_out else have = CHUNK - self[:avail_out] @output << @next_out.read_string(have) self[:next_out] = @next_out # Zlib advances self[:next_out] end self[:avail_out] = CHUNK end ## # Finishes the stream and flushes output buffer. See Zlib::Deflate#finish # and Zlib::Inflate#finish for details of this behavior. def finish run '', Zlib::FINISH detatch_output end ## # Returns true if the stream is finished. def finished? @flags & FINISHED == FINISHED end ## # Flushes output buffer and returns all data in that buffer. def flush_next_out detatch_output end def in_stream? @flags & IN_STREAM == IN_STREAM end def input_empty? @input.nil? or @input.empty? end ## # The msg field of the struct def message self[:msg] end def ready @flags |= READY end def ready? @flags & READY == READY end ## # Resets and initializes the stream. All data in both input and output # buffer are discarded. def reset err = Zlib.send @func_reset, pointer Zlib.handle_error err, message @flags = READY reset_input end def reset_input @input = nil end def run(data, flush) if @input.nil? and data.empty? then data_in = MemoryPointer.new 1 data_in.write_string "\000", 1 self[:next_in] = data_in self[:avail_in] = 0 else @input ||= '' @input << data data_in = MemoryPointer.new @input.length data_in.write_string @input, @input.length self[:next_in] = data_in self[:avail_in] = @input.length end expand_output if self[:avail_out] == 0 loop do err = Zlib.send @func_run, pointer, flush available = self[:avail_out] expand_output # HACK does this work when err is set? if err == Zlib::STREAM_END then @flags &= ~IN_STREAM @flags |= FINISHED break end unless err == Zlib::OK then if flush != Zlib::FINISH and err == Zlib::BUF_ERROR and self[:avail_out] > 0 then @flags |= IN_STREAM break end if self[:avail_in] > 0 then @input = self[:next_in].read_string(self[:avail_in]) + @input end Zlib.handle_error err, message end if available > 0 then @flags |= IN_STREAM break end end reset_input if self[:avail_in] > 0 then @input = self[:next_in].read_string self[:avail_in] end ensure data_in.free self[:next_in] = nil end ## # Returns the number of bytes consumed def total_in self[:total_in] end ## # Returns the number bytes processed def total_out self[:total_out] end end set_ffi_lib 'libz' # deflateInit2 is a macro pointing to deflateInit2_ attach_function :deflateInit2_, [ :pointer, # z_streamp strm :int, # int level :int, # int method :int, # int windowBits :int, # int memLevel :int, # int strategy :string, # ZLIB_VERSION :int # (int)sizeof(z_stream) ], :int def self.deflateInit2(stream, level, method, window_bits, mem_level, strategy) deflateInit2_ stream, level, method, window_bits, mem_level, strategy, ZLIB_VERSION, ZStream.size end attach_function :deflate, [:pointer, :int], :int attach_function :deflateEnd, [:pointer], :int attach_function :deflateParams, [:pointer, :int, :int], :int attach_function :deflateReset, [:pointer], :int attach_function :deflateSetDictionary, [:pointer, :string, :uint], :int # inflateInit2 is a macro pointing to inflateInit2_ attach_function :inflateInit2_, [:pointer, :int, :string, :int], :int def self.inflateInit2(stream, window_bits) inflateInit2_ stream, window_bits, ZLIB_VERSION, ZStream.size end attach_function :inflate, [:pointer, :int], :int attach_function :inflateEnd, [:pointer], :int attach_function :inflateReset, [:pointer], :int attach_function :inflateSetDictionary, [:pointer, :string, :uint], :int attach_function :adler32_c, :adler32, [:ulong, :string, :uint], :ulong attach_function :crc32_c, :crc32, [:ulong, :string, :uint], :ulong attach_function :get_crc_table_c, :get_crc_table, [], :pointer attach_function :zError, [:int], :string # Chunk size for inflation and deflation CHUNK = 1024 #-- # HACK from zlib.c #++ GZ_EXTRAFLAG_FAST = 0x4 GZ_EXTRAFLAG_SLOW = 0x2 ## # Zlib::Deflate is the class for compressing data. See Zlib::ZStream for # more information. class Deflate < ZStream ## # Compresses the given +string+. Valid values of level are # <tt>Zlib::NO_COMPRESSION</tt>, <tt>Zlib::BEST_SPEED</tt>, # <tt>Zlib::BEST_COMPRESSION</tt>, <tt>Zlib::DEFAULT_COMPRESSION</tt>, and # an integer from 0 to 9. # # This method is almost equivalent to the following code: # # def deflate(string, level) # z = Zlib::Deflate.new(level) # dst = z.deflate(string, Zlib::FINISH) # z.close # dst # end def self.deflate(data, level = Zlib::DEFAULT_COMPRESSION) deflator = new level zipped = deflator.deflate data, Zlib::FINISH zipped ensure deflator.end end ## # Creates a new deflate stream for compression. See zlib.h for details of # each argument. If an argument is nil, the default value of that argument # is used. def initialize(level = Zlib::DEFAULT_COMPRESSION, window_bits = Zlib::MAX_WBITS, mem_level = Zlib::DEF_MEM_LEVEL, strategy = Zlib::DEFAULT_STRATEGY) level ||= Zlib::DEFAULT_COMPRESSION window_bits ||= Zlib::MAX_WBITS mem_level ||= Zlib::DEF_MEM_LEVEL strategy ||= Zlib::DEFAULT_STRATEGY super() @func_end = :deflateEnd @func_reset = :deflateReset @func_run = :deflate err = Zlib.deflateInit2(pointer, level, Zlib::DEFLATED, window_bits, mem_level, strategy) Zlib.handle_error err, message ready end ## # Same as IO. def <<(data) do_deflate data, Zlib::NO_FLUSH self end ## # Inputs +string+ into the deflate stream and returns the output from the # stream. On calling this method, both the input and the output buffers # of the stream are flushed. If +string+ is nil, this method finishes the # stream, just like Zlib::ZStream#finish. # # The value of +flush+ should be either <tt>Zlib::NO_FLUSH</tt>, # <tt>Zlib::SYNC_FLUSH</tt>, <tt>Zlib::FULL_FLUSH</tt>, or # <tt>Zlib::FINISH</tt>. See zlib.h for details. def deflate(data, flush = Zlib::NO_FLUSH) do_deflate data, flush detatch_output end ## # Performs the deflate operation and leaves the compressed data in the # output buffer def do_deflate(data, flush) if data.nil? then run '', Zlib::FINISH else data = StringValue data if flush != Zlib::NO_FLUSH or not data.empty? then # prevent BUF_ERROR run data, flush end end end ## # Finishes compressing the deflate input stream and returns the output # buffer. def finish run '', Zlib::FINISH detatch_output end ## # This method is equivalent to <tt>deflate('', flush)</tt>. If flush is # omitted, <tt>Zlib::SYNC_FLUSH</tt> is used as flush. This method is # just provided to improve the readability of your Ruby program. def flush(flush = Zlib::SYNC_FLUSH) run '', flush unless flush == Zlib::NO_FLUSH detatch_output end ## # Changes the parameters of the deflate stream. See zlib.h for details. # The output from the stream by changing the params is preserved in output # buffer. def params(level, strategy) err = Zlib.deflateParams pointer, level, strategy raise Zlib::BufError, 'buffer expansion not implemented' if err == Zlib::BUF_ERROR Zlib.handle_error err, message nil end ## # Sets the preset dictionary and returns +dictionary+. This method is # available just only after Zlib::Deflate.new or Zlib::ZStream#reset # method was called. See zlib.h for details. def set_dictionary(dictionary) dict = StringValue dictionary err = Zlib.deflateSetDictionary pointer, dict, dict.length Zlib.handle_error err, message dictionary end end ## # Zlib::GzipFile is an abstract class for handling a gzip formatted # compressed file. The operations are defined in the subclasses, # Zlib::GzipReader for reading, and Zlib::GzipWriter for writing. # # GzipReader should be used by associating an IO, or IO-like, object. class GzipFile SYNC = Zlib::ZStream::UNUSED HEADER_FINISHED = Zlib::ZStream::UNUSED << 1 FOOTER_FINISHED = Zlib::ZStream::UNUSED << 2 FLAG_MULTIPART = 0x2 FLAG_EXTRA = 0x4 FLAG_ORIG_NAME = 0x8 FLAG_COMMENT = 0x10 FLAG_ENCRYPT = 0x20 FLAG_UNKNOWN_MASK = 0xc0 EXTRAFLAG_FAST = 0x4 EXTRAFLAG_SLOW = 0x2 MAGIC1 = 0x1f MAGIC2 = 0x8b METHOD_DEFLATE = 8 ## # Base class of errors that occur when processing GZIP files. class Error < Zlib::Error; end ## # Raised when gzip file footer is not found. class NoFooter < Error; end ## # Raised when the CRC checksum recorded in gzip file footer is not # equivalent to the CRC checksum of the actual uncompressed data. class CRCError < Error; end ## # Raised when the data length recorded in the gzip file footer is not # equivalent to the length of the actual uncompressed data. class LengthError < Error; end ## # Accessor for the underlying ZStream attr_reader :zstream # :nodoc: ## # See Zlib::GzipReader#wrap and Zlib::GzipWriter#wrap. def self.wrap(*args) obj = new(*args) if block_given? then begin yield obj ensure obj.close if obj.zstream.ready? end end end def initialize @comment = nil @crc = 0 @level = nil @mtime = Time.at 0 @orig_name = nil @os_code = Zlib::OS_CODE end ## # Closes the GzipFile object. This method calls close method of the # associated IO object. Returns the associated IO object. def close io = finish io.close if io.respond_to? :close io end ## # Same as IO def closed? @io.nil? end ## # Returns comments recorded in the gzip file header, or nil if the # comment is not present. def comment raise Error, 'closed gzip stream' if @io.nil? @comment.dup end def end return if @zstream.closing? @zstream.flags |= Zlib::ZStream::CLOSING begin end_run ensure @zstream.end end end ## # Closes the GzipFile object. Unlike Zlib::GzipFile#close, this method # never calls the close method of the associated IO object. Returns the # associated IO object. def finish self.end io = @io @io = nil @orig_name = nil @comment = nil io end def finished? @zstream.finished? and @zstream.output.empty? # HACK I think end def footer_finished? @zstream.flags & Zlib::GzipFile::FOOTER_FINISHED == Zlib::GzipFile::FOOTER_FINISHED end def header_finished? @zstream.flags & Zlib::GzipFile::HEADER_FINISHED == Zlib::GzipFile::HEADER_FINISHED end ## # Returns last modification time recorded in the gzip file header. def mtime Time.at @mtime end ## # Returns original filename recorded in the gzip file header, or +nil+ if # original filename is not present. def orig_name raise Error, 'closed gzip stream' if @io.nil? @orig_name.dup end end ## # Zlib::GzipReader is the class for reading a gzipped file. GzipReader # should be used an IO, or -IO-lie, object. # # Zlib::GzipReader.open('hoge.gz') {|gz| # print gz.read # } # # File.open('hoge.gz') do |f| # gz = Zlib::GzipReader.new(f) # print gz.read # gz.close # end # # == Method Catalogue # # The following methods in Zlib::GzipReader are just like their counterparts # in IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an # error was found in the gzip file. # # - #each # - #each_line # - #each_byte # - #gets # - #getc # - #lineno # - #lineno= # - #read # - #readchar # - #readline # - #readlines # - #ungetc # # Be careful of the footer of the gzip file. A gzip file has the checksum of # pre-compressed data in its footer. GzipReader checks all uncompressed data # against that checksum at the following cases, and if it fails, raises # <tt>Zlib::GzipFile::NoFooter</tt>, <tt>Zlib::GzipFile::CRCError</tt>, or # <tt>Zlib::GzipFile::LengthError</tt> exception. # # - When an reading request is received beyond the end of file (the end of # compressed data). That is, when Zlib::GzipReader#read, # Zlib::GzipReader#gets, or some other methods for reading returns nil. # - When Zlib::GzipFile#close method is called after the object reaches the # end of file. # - When Zlib::GzipReader#unused method is called after the object reaches # the end of file. # # The rest of the methods are adequately described in their own # documentation. class GzipReader < GzipFile # HACK use a buffer class ## # Creates a GzipReader object associated with +io+. The GzipReader object # reads gzipped data from +io+, and parses/decompresses them. At least, # +io+ must have a +read+ method that behaves same as the +read+ method in # IO class. # # If the gzip file header is incorrect, raises an Zlib::GzipFile::Error # exception. def initialize(io) @io = io @zstream = Zlib::Inflate.new -Zlib::MAX_WBITS @buffer = '' super() read_header end def check_footer @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED footer = @zstream.input.slice! 0, 8 rest = @io.read 8 - footer.length footer << rest if rest raise NoFooter, 'footer is not found' unless footer.length == 8 crc, length = footer.unpack 'VV' @zstream[:total_in] += 8 # to rewind correctly raise CRCError, 'invalid compressed data -- crc error' unless @crc == crc raise LengthError, 'invalid compressed data -- length error' unless length == @zstream.total_out end def end_run check_footer if @zstream.finished? and not footer_finished? end def eof? @zstream.finished? and @zstream.input_empty? end def pos @zstream[:total_out] - @buffer.length end ## # See Zlib::GzipReader documentation for a description. def read(length = nil) data = @buffer while chunk = @io.read(CHUNK) do inflated = @zstream.inflate(chunk) @crc = Zlib.crc32 inflated, @crc data << inflated break if length and data.length > length end if length then @buffer = data.slice! length..-1 else @buffer = '' end check_footer if @zstream.finished? and not footer_finished? data rescue Zlib::Error => e raise GzipFile::Error, e.message end def read_header header = @io.read 10 raise Error, 'not in gzip format' unless header.length == 10 magic1, magic2, method, flags, @mtime, extra_flags, @os_code = header.unpack 'CCCCVCC' unless magic1 == Zlib::GzipFile::MAGIC1 and magic2 == Zlib::GzipFile::MAGIC2 then raise Error, 'not in gzip format' end unless method == Zlib::GzipFile::METHOD_DEFLATE then raise Error, "unsupported compression method #{method}" end if flags & Zlib::GzipFile::FLAG_MULTIPART == Zlib::GzipFile::FLAG_MULTIPART then raise Error, 'multi-part gzip file is not supported' end if flags & Zlib::GzipFile::FLAG_ENCRYPT == Zlib::GzipFile::FLAG_ENCRYPT then raise Error, 'encrypted gzip file is not supported' end if flags & Zlib::GzipFile::FLAG_UNKNOWN_MASK == Zlib::GzipFile::FLAG_UNKNOWN_MASK then raise Error, "unknown flags 0x#{flags.to_s 16}" end if extra_flags & Zlib::GzipFile::EXTRAFLAG_FAST == Zlib::GzipFile::EXTRAFLAG_FAST then @level = Zlib::BEST_SPEED elsif extra_flags & Zlib::GzipFile::EXTRAFLAG_SLOW == Zlib::GzipFile::EXTRAFLAG_SLOW then @level = Zlib::BEST_COMPRESSION else @level = Zlib::DEFAULT_COMPRESSION end if flags & Zlib::GzipFile::FLAG_EXTRA == Zlib::GzipFile::FLAG_EXTRA then length = @io.read 2 raise Zlib::GzipFile::Error, 'unexpected end of file' if length.nil? or length.length != 2 length, = length.unpack 'v' extra = @io.read length + 2 raise Zlib::GzipFile::Error, 'unexpected end of file' if extra.nil? or extra.length != length + 2 end if flags & Zlib::GzipFile::FLAG_ORIG_NAME == Zlib::GzipFile::FLAG_ORIG_NAME then @orig_name = '' c = @io.getc until c == 0 do @orig_name << c.chr c = @io.getc end end if flags & Zlib::GzipFile::FLAG_COMMENT == Zlib::GzipFile::FLAG_COMMENT then @comment = '' c = @io.getc until c == 0 do @comment << c.chr c = @io.getc end end end end ## # Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should # be used with an instance of IO, or IO-like, object. # # For example: # # Zlib::GzipWriter.open('hoge.gz') do |gz| # gz.write 'jugemu jugemu gokou no surikire...' # end # # File.open('hoge.gz', 'w') do |f| # gz = Zlib::GzipWriter.new(f) # gz.write 'jugemu jugemu gokou no surikire...' # gz.close # end # # NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close # GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter # will be not able to write the gzip footer and will generate a broken gzip # file. class GzipWriter < GzipFile # HACK use a buffer class ## # Set the comment attr_writer :comment ## # Set the original name attr_writer :orig_name ## # Creates a GzipWriter object associated with +io+. +level+ and +strategy+ # should be the same as the arguments of Zlib::Deflate.new. The # GzipWriter object writes gzipped data to +io+. At least, +io+ must # respond to the +write+ method that behaves same as write method in IO # class. def initialize(io, level = Zlib::DEFAULT_COMPRESSION, strategy = Zlib::DEFAULT_STRATEGY) @io = io @zstream = Zlib::Deflate.new level, -Zlib::MAX_WBITS, Zlib::DEF_MEM_LEVEL, strategy @buffer = '' super() end def end_run make_header unless header_finished? @zstream.run '', Zlib::FINISH write_raw make_footer nil end ## # Flushes all the internal buffers of the GzipWriter object. The meaning # of +flush+ is same as in Zlib::Deflate#deflate. # <tt>Zlib::SYNC_FLUSH</tt> is used if +flush+ is omitted. It is no use # giving flush <tt>Zlib::NO_FLUSH</tt>. def flush true end ## # Writes out a gzip header def make_header flags = 0 extra_flags = 0 flags |= Zlib::GzipFile::FLAG_ORIG_NAME if @orig_name flags |= Zlib::GzipFile::FLAG_COMMENT if @comment extra_flags |= Zlib::GzipFile::EXTRAFLAG_FAST if @level == Zlib::BEST_SPEED extra_flags |= Zlib::GzipFile::EXTRAFLAG_SLOW if @level == Zlib::BEST_COMPRESSION header = [ Zlib::GzipFile::MAGIC1, # byte 0 Zlib::GzipFile::MAGIC2, # byte 1 Zlib::GzipFile::METHOD_DEFLATE, # byte 2 flags, # byte 3 @mtime.to_i, # bytes 4-7 extra_flags, # byte 8 @os_code # byte 9 ].pack 'CCCCVCC' @io.write header @io.write "#{@orig_name}\0" if @orig_name @io.write "#{@comment}\0" if @comment @zstream.flags |= Zlib::GzipFile::HEADER_FINISHED end ## # Writes out a gzip footer def make_footer footer = [ @crc, # bytes 0-3 @zstream.total_in, # bytes 4-7 ].pack 'VV' @io.write footer @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED end ## # Sets the modification time of this file def mtime=(time) if header_finished? then raise Zlib::GzipFile::Error, 'header is already written' end @mtime = Integer time end def sync? @zstream.flags & Zlib::GzipFile::SYNC == Zlib::GzipFile::SYNC end ## # Same as IO. def write(data) make_header unless header_finished? data = String data if data.length > 0 or sync? then @crc = Zlib.crc32_c @crc, data, data.length flush = sync? ? Zlib::SYNC_FLUSH : Zlib::NO_FLUSH @zstream.run data, flush end write_raw end ## # Same as IO. alias << write def write_raw data = @zstream.detatch_output unless data.empty? then @io.write data @io.flush if sync? and io.respond_to :flush end end end ## # Zlib:Inflate is the class for decompressing compressed data. Unlike # Zlib::Deflate, an instance of this class is not able to duplicate (clone, # dup) itself. class Inflate < ZStream ## # Decompresses +string+. Raises a Zlib::NeedDict exception if a preset # dictionary is needed for decompression. # # This method is almost equivalent to the following code: # # def inflate(string) # zstream = Zlib::Inflate.new # buf = zstream.inflate(string) # zstream.finish # zstream.close # buf # end def self.inflate(data) inflator = new unzipped = inflator.inflate data unzipped ensure inflator.end end ## # Creates a new inflate stream for decompression. See zlib.h for details # of the argument. If +window_bits+ is +nil+, the default value is used. def initialize(window_bits = Zlib::MAX_WBITS) super() @func_end = :inflateEnd @func_reset = :inflateReset @func_run = :inflate err = Zlib.inflateInit2 pointer, window_bits Zlib.handle_error err, message # HACK ready end ## # Inputs +string+ into the inflate stream just like Zlib::Inflate#inflate, # but returns the Zlib::Inflate object itself. The output from the stream # is preserved in output buffer. def <<(string) string = StringValue string unless string.nil? if finished? then unless string.nil? then @input ||= '' @input << string end else run string, Zlib::SYNC_FLUSH end end ## # Inputs +string+ into the inflate stream and returns the output from the # stream. Calling this method, both the input and the output buffer of # the stream are flushed. If string is +nil+, this method finishes the
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
true
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-darwin/sysconf.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-darwin/sysconf.rb
# This file is generated by rake. Do not edit. module Platform;end module Platform::Sysconf SC_2_CHAR_TERM = 20 SC_2_C_BIND = 18 SC_2_C_DEV = 19 SC_2_FORT_DEV = 21 SC_2_FORT_RUN = 22 SC_2_LOCALEDEF = 23 SC_2_PBS = 59 SC_2_PBS_ACCOUNTING = 60 SC_2_PBS_CHECKPOINT = 61 SC_2_PBS_LOCATE = 62 SC_2_PBS_MESSAGE = 63 SC_2_PBS_TRACK = 64 SC_2_SW_DEV = 24 SC_2_UPE = 25 SC_2_VERSION = 17 SC_ADVISORY_INFO = 65 SC_AIO_LISTIO_MAX = 42 SC_AIO_MAX = 43 SC_AIO_PRIO_DELTA_MAX = 44 SC_ARG_MAX = 1 SC_ASYNCHRONOUS_IO = 28 SC_ATEXIT_MAX = 107 SC_BARRIERS = 66 SC_BC_BASE_MAX = 9 SC_BC_DIM_MAX = 10 SC_BC_SCALE_MAX = 11 SC_BC_STRING_MAX = 12 SC_CHILD_MAX = 2 SC_CLK_TCK = 3 SC_CLOCK_SELECTION = 67 SC_COLL_WEIGHTS_MAX = 13 SC_CPUTIME = 68 SC_DELAYTIMER_MAX = 45 SC_EXPR_NEST_MAX = 14 SC_FILE_LOCKING = 69 SC_FSYNC = 38 SC_GETGR_R_SIZE_MAX = 70 SC_GETPW_R_SIZE_MAX = 71 SC_HOST_NAME_MAX = 72 SC_IOV_MAX = 56 SC_IPV6 = 118 SC_JOB_CONTROL = 6 SC_LINE_MAX = 15 SC_LOGIN_NAME_MAX = 73 SC_MAPPED_FILES = 47 SC_MEMLOCK = 30 SC_MEMLOCK_RANGE = 31 SC_MEMORY_PROTECTION = 32 SC_MESSAGE_PASSING = 33 SC_MONOTONIC_CLOCK = 74 SC_MQ_OPEN_MAX = 46 SC_MQ_PRIO_MAX = 75 SC_NGROUPS_MAX = 4 SC_NPROCESSORS_CONF = 57 SC_NPROCESSORS_ONLN = 58 SC_OPEN_MAX = 5 SC_PAGESIZE = 29 SC_PAGE_SIZE = 29 SC_PASS_MAX = 131 SC_PRIORITIZED_IO = 34 SC_PRIORITY_SCHEDULING = 35 SC_RAW_SOCKETS = 119 SC_READER_WRITER_LOCKS = 76 SC_REALTIME_SIGNALS = 36 SC_REGEXP = 77 SC_RE_DUP_MAX = 16 SC_RTSIG_MAX = 48 SC_SAVED_IDS = 7 SC_SEMAPHORES = 37 SC_SEM_NSEMS_MAX = 49 SC_SEM_VALUE_MAX = 50 SC_SHARED_MEMORY_OBJECTS = 39 SC_SHELL = 78 SC_SIGQUEUE_MAX = 51 SC_SPAWN = 79 SC_SPIN_LOCKS = 80 SC_SPORADIC_SERVER = 81 SC_SS_REPL_MAX = 126 SC_STREAM_MAX = 26 SC_SYMLOOP_MAX = 120 SC_SYNCHRONIZED_IO = 40 SC_THREADS = 96 SC_THREAD_ATTR_STACKADDR = 82 SC_THREAD_ATTR_STACKSIZE = 83 SC_THREAD_CPUTIME = 84 SC_THREAD_DESTRUCTOR_ITERATIONS = 85 SC_THREAD_KEYS_MAX = 86 SC_THREAD_PRIORITY_SCHEDULING = 89 SC_THREAD_PRIO_INHERIT = 87 SC_THREAD_PRIO_PROTECT = 88 SC_THREAD_PROCESS_SHARED = 90 SC_THREAD_SAFE_FUNCTIONS = 91 SC_THREAD_SPORADIC_SERVER = 92 SC_THREAD_STACK_MIN = 93 SC_THREAD_THREADS_MAX = 94 SC_TIMEOUTS = 95 SC_TIMERS = 41 SC_TIMER_MAX = 52 SC_TRACE = 97 SC_TRACE_EVENT_FILTER = 98 SC_TRACE_EVENT_NAME_MAX = 127 SC_TRACE_INHERIT = 99 SC_TRACE_LOG = 100 SC_TRACE_NAME_MAX = 128 SC_TRACE_SYS_MAX = 129 SC_TRACE_USER_EVENT_MAX = 130 SC_TTY_NAME_MAX = 101 SC_TYPED_MEMORY_OBJECTS = 102 SC_TZNAME_MAX = 27 SC_V6_ILP32_OFF32 = 103 SC_V6_ILP32_OFFBIG = 104 SC_V6_LP64_OFF64 = 105 SC_V6_LPBIG_OFFBIG = 106 SC_VERSION = 8 SC_XBS5_ILP32_OFF32 = 122 SC_XBS5_ILP32_OFFBIG = 123 SC_XBS5_LP64_OFF64 = 124 SC_XBS5_LPBIG_OFFBIG = 125 SC_XOPEN_CRYPT = 108 SC_XOPEN_ENH_I18N = 109 SC_XOPEN_LEGACY = 110 SC_XOPEN_REALTIME = 111 SC_XOPEN_REALTIME_THREADS = 112 SC_XOPEN_SHM = 113 SC_XOPEN_STREAMS = 114 SC_XOPEN_UNIX = 115 SC_XOPEN_VERSION = 116 SC_XOPEN_XCU_VERSION = 121 end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/sparc-solaris/errno.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/sparc-solaris/errno.rb
# This file is generated by rake. Do not edit. module Platform; end module Platform::Errno E2BIG = 7 EACCES = 13 EADDRINUSE = 125 EADDRNOTAVAIL = 126 EAFNOSUPPORT = 124 EAGAIN = 11 EALREADY = 149 EBADF = 9 EBUSY = 16 ECHILD = 10 ECONNABORTED = 130 ECONNREFUSED = 146 ECONNRESET = 131 EDEADLK = 45 EDESTADDRREQ = 96 EEXIST = 17 EFAULT = 14 EFBIG = 27 EHOSTDOWN = 147 EHOSTUNREACH = 148 EINPROGRESS = 150 EINTR = 4 EINVAL = 22 EIO = 5 EISCONN = 133 EISDIR = 21 ELOOP = 90 EMFILE = 24 EMLINK = 31 EMSGSIZE = 97 ENAMETOOLONG = 78 ENETDOWN = 127 ENETRESET = 129 ENETUNREACH = 128 ENFILE = 23 ENOBUFS = 132 ENODEV = 19 ENOENT = 2 ENOEXEC = 8 ENOMEM = 12 ENOPROTOOPT = 99 ENOSPC = 28 ENOTCONN = 134 ENOTDIR = 20 ENOTEMPTY = 93 ENOTSOCK = 95 ENOTTY = 25 ENXIO = 6 EOPNOTSUPP = 122 EPERM = 1 EPIPE = 32 EPROTONOSUPPORT = 120 EPROTOTYPE = 98 EROFS = 30 ESPIPE = 29 ESRCH = 3 ETIMEDOUT = 145 ETXTBSY = 26 EWOULDBLOCK = 11 EXDEV = 18 end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/sparc-solaris/socket.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/sparc-solaris/socket.rb
# This file is generated by rake. Do not edit. module Platform; end module Platform::Socket AF_APPLETALK = 16 # AF_ATM not available # AF_AX25 not available AF_CCITT = 10 AF_CHAOS = 5 # AF_CNT not available # AF_COIP not available AF_DATAKIT = 9 AF_DECnet = 12 AF_DLI = 13 # AF_E164 not available AF_ECMA = 8 AF_HYLINK = 15 AF_IMPLINK = 3 AF_INET = 2 AF_INET6 = 26 AF_IPX = 23 # AF_ISDN not available # AF_ISO not available AF_LAT = 14 AF_LINK = 25 # AF_LOCAL not available AF_MAX = 29 # AF_NATM not available # AF_NDRV not available # AF_NETBIOS not available # AF_NETGRAPH not available AF_NS = 6 AF_OSI = 19 # AF_PPP not available AF_PUP = 4 AF_ROUTE = 24 # AF_SIP not available AF_SNA = 11 # AF_SYSTEM not available AF_UNIX = 1 AF_UNSPEC = 0 NI_DGRAM = 16 # NI_FQDN_FLAG_VALIDTTL not available NI_MAXHOST = 1025 NI_MAXSERV = 32 NI_NAMEREQD = 4 # NI_NODEADDR_FLAG_ALL not available # NI_NODEADDR_FLAG_ANYCAST not available # NI_NODEADDR_FLAG_COMPAT not available # NI_NODEADDR_FLAG_GLOBAL not available # NI_NODEADDR_FLAG_LINKLOCAL not available # NI_NODEADDR_FLAG_SITELOCAL not available # NI_NODEADDR_FLAG_TRUNCATE not available NI_NOFQDN = 1 NI_NUMERICHOST = 2 NI_NUMERICSERV = 8 # NI_QTYPE_DNSNAME not available # NI_QTYPE_FQDN not available # NI_QTYPE_IPV4ADDR not available # NI_QTYPE_NODEADDR not available # NI_QTYPE_NOOP not available # NI_QTYPE_SUPTYPES not available # NI_SUPTYPE_FLAG_COMPRESS not available NI_WITHSCOPEID = 32 PF_APPLETALK = 16 # PF_ATM not available PF_CCITT = 10 PF_CHAOS = 5 # PF_CNT not available # PF_COIP not available PF_DATAKIT = 9 PF_DECnet = 12 PF_DLI = 13 PF_ECMA = 8 PF_HYLINK = 15 PF_IMPLINK = 3 PF_INET = 2 PF_INET6 = 26 PF_IPX = 23 # PF_ISDN not available # PF_ISO not available PF_KEY = 27 PF_LAT = 14 PF_LINK = 25 # PF_LOCAL not available PF_MAX = 29 # PF_NATM not available # PF_NDRV not available # PF_NETBIOS not available # PF_NETGRAPH not available PF_NS = 6 PF_OSI = 19 # PF_PIP not available # PF_PPP not available PF_PUP = 4 PF_ROUTE = 24 # PF_RTIP not available # PF_SIP not available PF_SNA = 11 # PF_SYSTEM not available PF_UNIX = 1 PF_UNSPEC = 0 # PF_XTP not available SOCK_DGRAM = 1 # SOCK_MAXADDRLEN not available SOCK_RAW = 4 SOCK_RDM = 5 SOCK_SEQPACKET = 6 SOCK_STREAM = 2 SO_ACCEPTCONN = 2 # SO_ACCEPTFILTER not available # SO_ATTACH_FILTER not available # SO_BINDTODEVICE not available SO_BROADCAST = 32 SO_DEBUG = 1 # SO_DETACH_FILTER not available SO_DONTROUTE = 16 # SO_DONTTRUNC not available SO_ERROR = 4103 SO_KEEPALIVE = 8 # SO_LABEL not available SO_LINGER = 128 # SO_NKE not available # SO_NOADDRERR not available # SO_NOSIGPIPE not available # SO_NO_CHECK not available # SO_NREAD not available # SO_NWRITE not available SO_OOBINLINE = 256 # SO_PASSCRED not available # SO_PEERCRED not available # SO_PEERLABEL not available # SO_PEERNAME not available # SO_PRIORITY not available SO_RCVBUF = 4098 SO_RCVLOWAT = 4100 SO_RCVTIMEO = 4102 SO_REUSEADDR = 4 # SO_REUSEPORT not available # SO_REUSESHAREUID not available # SO_SECURITY_AUTHENTICATION not available # SO_SECURITY_ENCRYPTION_NETWORK not available # SO_SECURITY_ENCRYPTION_TRANSPORT not available SO_SNDBUF = 4097 SO_SNDLOWAT = 4099 SO_SNDTIMEO = 4101 # SO_TIMESTAMP not available SO_TYPE = 4104 SO_USELOOPBACK = 64 # SO_WANTMORE not available # SO_WANTOOBFLAG not available # pseudo_AF_HDRCMPLT not available # pseudo_AF_KEY not available # pseudo_AF_PIP not available # pseudo_AF_RTIP not available # pseudo_AF_XTP not available end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/sparc-solaris/stat.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/sparc-solaris/stat.rb
# This file is generated by rake. Do not edit. module Platform module Stat class Stat < FFI::Struct self.size = 152 layout :st_dev, :dev_t, 0, :st_ino, :ino_t, 16, :st_nlink, :nlink_t, 28, :st_mode, :mode_t, 24, :st_uid, :uid_t, 32, :st_gid, :gid_t, 36, :st_size, :off_t, 56, :st_blocks, :blkcnt_t, 96, :st_atime, :time_t, 64, :st_mtime, :time_t, 72, :st_ctime, :time_t, 80 end module Constants S_IEXEC = 0x40 S_IREAD = 0x100 S_IRGRP = 0x20 S_IROTH = 0x4 S_IRUSR = 0x100 S_IRWXG = 0x38 S_IRWXO = 0x7 S_IRWXU = 0x1c0 S_ISGID = 0x400 S_ISUID = 0x800 S_IWGRP = 0x10 S_IWOTH = 0x2 S_IWRITE = 0x80 S_IWUSR = 0x80 S_IXGRP = 0x8 S_IXOTH = 0x1 S_IXUSR = 0x40 end include Constants end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/sparc-solaris/etc.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/sparc-solaris/etc.rb
# This file is generated by rake. Do not edit. module Platform; end module Platform::Etc class Passwd < FFI::Struct self.size = 36 layout :pw_name, :string, 0, :pw_passwd, :string, 4, :pw_uid, :uint, 8, :pw_gid, :uint, 12, :pw_dir, :string, 28, :pw_shell, :string, 32 end class Group < FFI::Struct self.size = 16 layout :gr_name, :string, 0, :gr_gid, :uint, 8 end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/sparc-solaris/syslog.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/sparc-solaris/syslog.rb
# This file is generated by rake. Do not edit. module Syslog module Constants LOG_ALERT = 1 LOG_AUTH = 32 # LOG_AUTHPRIV not available LOG_CONS = 2 # LOG_CONSOLE not available LOG_CRIT = 2 LOG_CRON = 120 LOG_DAEMON = 24 LOG_DEBUG = 7 LOG_EMERG = 0 LOG_ERR = 3 # LOG_FTP not available LOG_INFO = 6 LOG_KERN = 0 LOG_LOCAL0 = 128 LOG_LOCAL1 = 136 LOG_LOCAL2 = 144 LOG_LOCAL3 = 152 LOG_LOCAL4 = 160 LOG_LOCAL5 = 168 LOG_LOCAL6 = 176 LOG_LOCAL7 = 184 LOG_LPR = 48 LOG_MAIL = 16 LOG_NEWS = 56 # LOG_NODELAY not available LOG_NOTICE = 5 LOG_NOWAIT = 16 # LOG_NTP not available LOG_ODELAY = 4 # LOG_PERROR not available LOG_PID = 1 # LOG_SECURITY not available LOG_SYSLOG = 40 LOG_USER = 8 LOG_UUCP = 64 LOG_WARNING = 4 end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/sparc-solaris/fcntl.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/sparc-solaris/fcntl.rb
# This file is generated by rake. Do not edit. module Fcntl FD_CLOEXEC = 1 F_DUPFD = 0 F_GETFD = 1 F_GETFL = 3 F_GETLK = 33 F_RDLCK = 1 F_SETFD = 2 F_SETFL = 4 F_SETLK = 34 F_SETLKW = 35 F_UNLCK = 3 F_WRLCK = 2 O_ACCMODE = 3 O_APPEND = 8 O_CREAT = 256 O_EXCL = 1024 O_NDELAY = 4 O_NOCTTY = 2048 O_NONBLOCK = 128 O_RDONLY = 0 O_RDWR = 2 O_TRUNC = 512 O_WRONLY = 1 end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/sparc-solaris/zlib.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/sparc-solaris/zlib.rb
# This file is generated by rake. Do not edit. ## # The Zlib module contains several classes for compressing and decompressing # streams, and for working with "gzip" files. # # == Classes # # Following are the classes that are most likely to be of interest to the # user: # - Zlib::Inflate # - Zlib::Deflate # - Zlib::GzipReader # - Zlib::GzipWriter # # There are two important base classes for the classes above: Zlib::ZStream # and Zlib::GzipFile. Everything else is an error class. # # == Constants # # Here's a list. # # Zlib::VERSION # The Ruby/zlib version string. # # Zlib::ZLIB_VERSION # The string which represents the version of zlib.h. # # Zlib::BINARY # Zlib::ASCII # Zlib::UNKNOWN # The integers representing data types which Zlib::ZStream#data_type # method returns. # # Zlib::NO_COMPRESSION # Zlib::BEST_SPEED # Zlib::BEST_COMPRESSION # Zlib::DEFAULT_COMPRESSION # The integers representing compression levels which are an argument # for Zlib::Deflate.new, Zlib::Deflate#deflate, and so on. # # Zlib::FILTERED # Zlib::HUFFMAN_ONLY # Zlib::DEFAULT_STRATEGY # The integers representing compression methods which are an argument # for Zlib::Deflate.new and Zlib::Deflate#params. # # Zlib::DEF_MEM_LEVEL # Zlib::MAX_MEM_LEVEL # The integers representing memory levels which are an argument for # Zlib::Deflate.new, Zlib::Deflate#params, and so on. # # Zlib::MAX_WBITS # The default value of windowBits which is an argument for # Zlib::Deflate.new and Zlib::Inflate.new. # # Zlib::NO_FLUSH # Zlib::SYNC_FLUSH # Zlib::FULL_FLUSH # Zlib::FINISH # The integers to control the output of the deflate stream, which are # an argument for Zlib::Deflate#deflate and so on. #-- # These constants are missing! # # Zlib::OS_CODE # Zlib::OS_MSDOS # Zlib::OS_AMIGA # Zlib::OS_VMS # Zlib::OS_UNIX # Zlib::OS_VMCMS # Zlib::OS_ATARI # Zlib::OS_OS2 # Zlib::OS_MACOS # Zlib::OS_ZSYSTEM # Zlib::OS_CPM # Zlib::OS_TOPS20 # Zlib::OS_WIN32 # Zlib::OS_QDOS # Zlib::OS_RISCOS # Zlib::OS_UNKNOWN # The return values of Zlib::GzipFile#os_code method. module Zlib ZLIB_VERSION = "1.2.3" BEST_COMPRESSION = 9 BEST_SPEED = 1 BLOCK = 5 BUF_ERROR = -5 DATA_ERROR = -3 DEFAULT_COMPRESSION = -1 DEFAULT_STRATEGY = 0 DEFLATED = 8 ERRNO = -1 FILTERED = 1 FINISH = 4 FIXED = 4 FULL_FLUSH = 3 HUFFMAN_ONLY = 2 MEM_ERROR = -4 NEED_DICT = 2 NO_COMPRESSION = 0 NO_FLUSH = 0 OK = 0 PARTIAL_FLUSH = 1 RLE = 3 STREAM_END = 1 STREAM_ERROR = -2 SYNC_FLUSH = 2 VERSION_ERROR = -6 # DEF_MEM_LEVEL not available MAX_MEM_LEVEL = 9 MAX_WBITS = 15 OS_MSDOS = 0x00 OS_AMIGA = 0x01 OS_VMS = 0x02 OS_UNIX = 0x03 OS_ATARI = 0x05 OS_OS2 = 0x06 OS_MACOS = 0x07 OS_TOPS20 = 0x0a OS_WIN32 = 0x0b OS_VMCMS = 0x04 OS_ZSYSTEM = 0x08 OS_CPM = 0x09 OS_QDOS = 0x0c OS_RISCOS = 0x0d OS_UNKNOWN = 0xff # OS_CODE not available unless defined? OS_CODE then OS_CODE = OS_UNIX end # from zutil.h unless defined? DEF_MEM_LEVEL then DEF_MEM_LEVEL = MAX_MEM_LEVEL >= 8 ? 8 : MAX_MEM_LEVEL end class Error < StandardError; end class StreamEnd < Error; end class NeedDict < Error; end class StreamError < Error; end class DataError < Error; end class BufError < Error; end class VersionError < Error; end class MemError < Error; end ## # Zlib::ZStream is the abstract class for the stream which handles the # compressed data. The operations are defined in the subclasses: # Zlib::Deflate for compression, and Zlib::Inflate for decompression. # # An instance of Zlib::ZStream has one stream (struct zstream in the source) # and two variable-length buffers which associated to the input (next_in) of # the stream and the output (next_out) of the stream. In this document, # "input buffer" means the buffer for input, and "output buffer" means the # buffer for output. # # Data input into an instance of Zlib::ZStream are temporally stored into # the end of input buffer, and then data in input buffer are processed from # the beginning of the buffer until no more output from the stream is # produced (i.e. until avail_out > 0 after processing). During processing, # output buffer is allocated and expanded automatically to hold all output # data. # # Some particular instance methods consume the data in output buffer and # return them as a String. # # Here is an ascii art for describing above: # # +================ an instance of Zlib::ZStream ================+ # || || # || +--------+ +-------+ +--------+ || # || +--| output |<---------|zstream|<---------| input |<--+ || # || | | buffer | next_out+-------+next_in | buffer | | || # || | +--------+ +--------+ | || # || | | || # +===|======================================================|===+ # | | # v | # "output data" "input data" # # If an error occurs during processing input buffer, an exception which is a # subclass of Zlib::Error is raised. At that time, both input and output # buffer keep their conditions at the time when the error occurs. # # == Method Catalogue # # Many of the methods in this class are fairly low-level and unlikely to be # of interest to users. In fact, users are unlikely to use this class # directly; rather they will be interested in Zlib::Inflate and # Zlib::Deflate. # # The higher level methods are listed below. # # - #total_in # - #total_out # - #data_type # - #adler # - #reset # - #finish # - #finished? # - #close # - #closed? class ZStream < FFI::Struct self.size = 56 layout :next_in, :pointer, 0, :avail_in, :uint, 4, :total_in, :ulong, 8, :next_out, :pointer, 12, :avail_out, :uint, 16, :total_out, :ulong, 20, :msg, :string, 24, :state, :pointer, 28, :zalloc, :pointer, 32, :zfree, :pointer, 36, :opaque, :pointer, 40, :data_type, :int, 44, :adler, :ulong, 48, :reserved, :ulong, 52 #-- # HACK from MRI's zlib.c #++ READY = 0x1 IN_STREAM = 0x2 FINISHED = 0x4 CLOSING = 0x8 UNUSED = 0x10 attr_accessor :flags attr_reader :input attr_reader :output def self.inherited(subclass) subclass.instance_variable_set :@layout, @layout subclass.instance_variable_set :@size, @size end def initialize super self[:avail_in] = 0 self[:avail_out] = 0 self[:next_in] = nil self[:opaque] = nil self[:zalloc] = nil self[:zfree] = nil reset_input @output = nil @flags = 0 @func = nil end def closing? @flags & CLOSING == CLOSING end def detatch_output if @output.nil? then data = '' else data = @output @output = nil self[:avail_out] = 0 self[:next_out] = nil end data end ## # Closes the stream. All operations on the closed stream will raise an # exception. def end unless ready? then warn "attempt to close uninitialized stream; ignored." return nil end if in_stream? then warn "attempt to close unfinished zstream; reset forced" reset end reset_input err = Zlib.send @func_end, pointer Zlib.handle_error err, message @flags = 0 # HACK this may be wrong @output = nil @next_out.free unless @next_out.nil? @next_out = nil nil end alias :close :end def expand_output if @output.nil? then @output = '' @next_out = MemoryPointer.new CHUNK if @next_out.nil? @next_out.write_string "\000" * CHUNK self[:next_out] = @next_out else have = CHUNK - self[:avail_out] @output << @next_out.read_string(have) self[:next_out] = @next_out # Zlib advances self[:next_out] end self[:avail_out] = CHUNK end ## # Finishes the stream and flushes output buffer. See Zlib::Deflate#finish # and Zlib::Inflate#finish for details of this behavior. def finish run '', Zlib::FINISH detatch_output end ## # Returns true if the stream is finished. def finished? @flags & FINISHED == FINISHED end ## # Flushes output buffer and returns all data in that buffer. def flush_next_out detatch_output end def in_stream? @flags & IN_STREAM == IN_STREAM end def input_empty? @input.nil? or @input.empty? end ## # The msg field of the struct def message self[:msg] end def ready @flags |= READY end def ready? @flags & READY == READY end ## # Resets and initializes the stream. All data in both input and output # buffer are discarded. def reset err = Zlib.send @func_reset, pointer Zlib.handle_error err, message @flags = READY reset_input end def reset_input @input = nil end def run(data, flush) if @input.nil? and data.empty? then data_in = MemoryPointer.new 1 data_in.write_string "\000", 1 self[:next_in] = data_in self[:avail_in] = 0 else @input ||= '' @input << data data_in = MemoryPointer.new @input.length data_in.write_string @input, @input.length self[:next_in] = data_in self[:avail_in] = @input.length end expand_output if self[:avail_out] == 0 loop do err = Zlib.send @func_run, pointer, flush available = self[:avail_out] expand_output # HACK does this work when err is set? if err == Zlib::STREAM_END then @flags &= ~IN_STREAM @flags |= FINISHED break end unless err == Zlib::OK then if flush != Zlib::FINISH and err == Zlib::BUF_ERROR and self[:avail_out] > 0 then @flags |= IN_STREAM break end if self[:avail_in] > 0 then @input = self[:next_in].read_string(self[:avail_in]) + @input end Zlib.handle_error err, message end if available > 0 then @flags |= IN_STREAM break end end reset_input if self[:avail_in] > 0 then @input = self[:next_in].read_string self[:avail_in] end ensure data_in.free self[:next_in] = nil end ## # Returns the number of bytes consumed def total_in self[:total_in] end ## # Returns the number bytes processed def total_out self[:total_out] end end set_ffi_lib 'libz' # deflateInit2 is a macro pointing to deflateInit2_ attach_function :deflateInit2_, [ :pointer, # z_streamp strm :int, # int level :int, # int method :int, # int windowBits :int, # int memLevel :int, # int strategy :string, # ZLIB_VERSION :int # (int)sizeof(z_stream) ], :int def self.deflateInit2(stream, level, method, window_bits, mem_level, strategy) deflateInit2_ stream, level, method, window_bits, mem_level, strategy, ZLIB_VERSION, ZStream.size end attach_function :deflate, [:pointer, :int], :int attach_function :deflateEnd, [:pointer], :int attach_function :deflateParams, [:pointer, :int, :int], :int attach_function :deflateReset, [:pointer], :int attach_function :deflateSetDictionary, [:pointer, :string, :uint], :int # inflateInit2 is a macro pointing to inflateInit2_ attach_function :inflateInit2_, [:pointer, :int, :string, :int], :int def self.inflateInit2(stream, window_bits) inflateInit2_ stream, window_bits, ZLIB_VERSION, ZStream.size end attach_function :inflate, [:pointer, :int], :int attach_function :inflateEnd, [:pointer], :int attach_function :inflateReset, [:pointer], :int attach_function :inflateSetDictionary, [:pointer, :string, :uint], :int attach_function :adler32_c, :adler32, [:ulong, :string, :uint], :ulong attach_function :crc32_c, :crc32, [:ulong, :string, :uint], :ulong attach_function :get_crc_table_c, :get_crc_table, [], :pointer attach_function :zError, [:int], :string # Chunk size for inflation and deflation CHUNK = 1024 #-- # HACK from zlib.c #++ GZ_EXTRAFLAG_FAST = 0x4 GZ_EXTRAFLAG_SLOW = 0x2 ## # Zlib::Deflate is the class for compressing data. See Zlib::ZStream for # more information. class Deflate < ZStream ## # Compresses the given +string+. Valid values of level are # <tt>Zlib::NO_COMPRESSION</tt>, <tt>Zlib::BEST_SPEED</tt>, # <tt>Zlib::BEST_COMPRESSION</tt>, <tt>Zlib::DEFAULT_COMPRESSION</tt>, and # an integer from 0 to 9. # # This method is almost equivalent to the following code: # # def deflate(string, level) # z = Zlib::Deflate.new(level) # dst = z.deflate(string, Zlib::FINISH) # z.close # dst # end def self.deflate(data, level = Zlib::DEFAULT_COMPRESSION) deflator = new level zipped = deflator.deflate data, Zlib::FINISH zipped ensure deflator.end end ## # Creates a new deflate stream for compression. See zlib.h for details of # each argument. If an argument is nil, the default value of that argument # is used. def initialize(level = Zlib::DEFAULT_COMPRESSION, window_bits = Zlib::MAX_WBITS, mem_level = Zlib::DEF_MEM_LEVEL, strategy = Zlib::DEFAULT_STRATEGY) level ||= Zlib::DEFAULT_COMPRESSION window_bits ||= Zlib::MAX_WBITS mem_level ||= Zlib::DEF_MEM_LEVEL strategy ||= Zlib::DEFAULT_STRATEGY super() @func_end = :deflateEnd @func_reset = :deflateReset @func_run = :deflate err = Zlib.deflateInit2(pointer, level, Zlib::DEFLATED, window_bits, mem_level, strategy) Zlib.handle_error err, message ready end ## # Same as IO. def <<(data) do_deflate data, Zlib::NO_FLUSH self end ## # Inputs +string+ into the deflate stream and returns the output from the # stream. On calling this method, both the input and the output buffers # of the stream are flushed. If +string+ is nil, this method finishes the # stream, just like Zlib::ZStream#finish. # # The value of +flush+ should be either <tt>Zlib::NO_FLUSH</tt>, # <tt>Zlib::SYNC_FLUSH</tt>, <tt>Zlib::FULL_FLUSH</tt>, or # <tt>Zlib::FINISH</tt>. See zlib.h for details. def deflate(data, flush = Zlib::NO_FLUSH) do_deflate data, flush detatch_output end ## # Performs the deflate operation and leaves the compressed data in the # output buffer def do_deflate(data, flush) if data.nil? then run '', Zlib::FINISH else data = StringValue data if flush != Zlib::NO_FLUSH or not data.empty? then # prevent BUF_ERROR run data, flush end end end ## # Finishes compressing the deflate input stream and returns the output # buffer. def finish run '', Zlib::FINISH detatch_output end ## # This method is equivalent to <tt>deflate('', flush)</tt>. If flush is # omitted, <tt>Zlib::SYNC_FLUSH</tt> is used as flush. This method is # just provided to improve the readability of your Ruby program. def flush(flush = Zlib::SYNC_FLUSH) run '', flush unless flush == Zlib::NO_FLUSH detatch_output end ## # Changes the parameters of the deflate stream. See zlib.h for details. # The output from the stream by changing the params is preserved in output # buffer. def params(level, strategy) err = Zlib.deflateParams pointer, level, strategy raise Zlib::BufError, 'buffer expansion not implemented' if err == Zlib::BUF_ERROR Zlib.handle_error err, message nil end ## # Sets the preset dictionary and returns +dictionary+. This method is # available just only after Zlib::Deflate.new or Zlib::ZStream#reset # method was called. See zlib.h for details. def set_dictionary(dictionary) dict = StringValue dictionary err = Zlib.deflateSetDictionary pointer, dict, dict.length Zlib.handle_error err, message dictionary end end ## # Zlib::GzipFile is an abstract class for handling a gzip formatted # compressed file. The operations are defined in the subclasses, # Zlib::GzipReader for reading, and Zlib::GzipWriter for writing. # # GzipReader should be used by associating an IO, or IO-like, object. class GzipFile SYNC = Zlib::ZStream::UNUSED HEADER_FINISHED = Zlib::ZStream::UNUSED << 1 FOOTER_FINISHED = Zlib::ZStream::UNUSED << 2 FLAG_MULTIPART = 0x2 FLAG_EXTRA = 0x4 FLAG_ORIG_NAME = 0x8 FLAG_COMMENT = 0x10 FLAG_ENCRYPT = 0x20 FLAG_UNKNOWN_MASK = 0xc0 EXTRAFLAG_FAST = 0x4 EXTRAFLAG_SLOW = 0x2 MAGIC1 = 0x1f MAGIC2 = 0x8b METHOD_DEFLATE = 8 ## # Base class of errors that occur when processing GZIP files. class Error < Zlib::Error; end ## # Raised when gzip file footer is not found. class NoFooter < Error; end ## # Raised when the CRC checksum recorded in gzip file footer is not # equivalent to the CRC checksum of the actual uncompressed data. class CRCError < Error; end ## # Raised when the data length recorded in the gzip file footer is not # equivalent to the length of the actual uncompressed data. class LengthError < Error; end ## # Accessor for the underlying ZStream attr_reader :zstream # :nodoc: ## # See Zlib::GzipReader#wrap and Zlib::GzipWriter#wrap. def self.wrap(*args) obj = new(*args) if block_given? then begin yield obj ensure obj.close if obj.zstream.ready? end end end def initialize @comment = nil @crc = 0 @level = nil @mtime = Time.at 0 @orig_name = nil @os_code = Zlib::OS_CODE end ## # Closes the GzipFile object. This method calls close method of the # associated IO object. Returns the associated IO object. def close io = finish io.close if io.respond_to? :close io end ## # Same as IO def closed? @io.nil? end ## # Returns comments recorded in the gzip file header, or nil if the # comment is not present. def comment raise Error, 'closed gzip stream' if @io.nil? @comment.dup end def end return if @zstream.closing? @zstream.flags |= Zlib::ZStream::CLOSING begin end_run ensure @zstream.end end end ## # Closes the GzipFile object. Unlike Zlib::GzipFile#close, this method # never calls the close method of the associated IO object. Returns the # associated IO object. def finish self.end io = @io @io = nil @orig_name = nil @comment = nil io end def finished? @zstream.finished? and @zstream.output.empty? # HACK I think end def footer_finished? @zstream.flags & Zlib::GzipFile::FOOTER_FINISHED == Zlib::GzipFile::FOOTER_FINISHED end def header_finished? @zstream.flags & Zlib::GzipFile::HEADER_FINISHED == Zlib::GzipFile::HEADER_FINISHED end ## # Returns last modification time recorded in the gzip file header. def mtime Time.at @mtime end ## # Returns original filename recorded in the gzip file header, or +nil+ if # original filename is not present. def orig_name raise Error, 'closed gzip stream' if @io.nil? @orig_name.dup end end ## # Zlib::GzipReader is the class for reading a gzipped file. GzipReader # should be used an IO, or -IO-lie, object. # # Zlib::GzipReader.open('hoge.gz') {|gz| # print gz.read # } # # File.open('hoge.gz') do |f| # gz = Zlib::GzipReader.new(f) # print gz.read # gz.close # end # # == Method Catalogue # # The following methods in Zlib::GzipReader are just like their counterparts # in IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an # error was found in the gzip file. # # - #each # - #each_line # - #each_byte # - #gets # - #getc # - #lineno # - #lineno= # - #read # - #readchar # - #readline # - #readlines # - #ungetc # # Be careful of the footer of the gzip file. A gzip file has the checksum of # pre-compressed data in its footer. GzipReader checks all uncompressed data # against that checksum at the following cases, and if it fails, raises # <tt>Zlib::GzipFile::NoFooter</tt>, <tt>Zlib::GzipFile::CRCError</tt>, or # <tt>Zlib::GzipFile::LengthError</tt> exception. # # - When an reading request is received beyond the end of file (the end of # compressed data). That is, when Zlib::GzipReader#read, # Zlib::GzipReader#gets, or some other methods for reading returns nil. # - When Zlib::GzipFile#close method is called after the object reaches the # end of file. # - When Zlib::GzipReader#unused method is called after the object reaches # the end of file. # # The rest of the methods are adequately described in their own # documentation. class GzipReader < GzipFile # HACK use a buffer class ## # Creates a GzipReader object associated with +io+. The GzipReader object # reads gzipped data from +io+, and parses/decompresses them. At least, # +io+ must have a +read+ method that behaves same as the +read+ method in # IO class. # # If the gzip file header is incorrect, raises an Zlib::GzipFile::Error # exception. def initialize(io) @io = io @zstream = Zlib::Inflate.new -Zlib::MAX_WBITS @buffer = '' super() read_header end def check_footer @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED footer = @zstream.input.slice! 0, 8 rest = @io.read 8 - footer.length footer << rest if rest raise NoFooter, 'footer is not found' unless footer.length == 8 crc, length = footer.unpack 'VV' @zstream[:total_in] += 8 # to rewind correctly raise CRCError, 'invalid compressed data -- crc error' unless @crc == crc raise LengthError, 'invalid compressed data -- length error' unless length == @zstream.total_out end def end_run check_footer if @zstream.finished? and not footer_finished? end def eof? @zstream.finished? and @zstream.input_empty? end def pos @zstream[:total_out] - @buffer.length end ## # See Zlib::GzipReader documentation for a description. def read(length = nil) data = @buffer while chunk = @io.read(CHUNK) do inflated = @zstream.inflate(chunk) @crc = Zlib.crc32 inflated, @crc data << inflated break if length and data.length > length end if length then @buffer = data.slice! length..-1 else @buffer = '' end check_footer if @zstream.finished? and not footer_finished? data rescue Zlib::Error => e raise GzipFile::Error, e.message end def read_header header = @io.read 10 raise Error, 'not in gzip format' unless header.length == 10 magic1, magic2, method, flags, @mtime, extra_flags, @os_code = header.unpack 'CCCCVCC' unless magic1 == Zlib::GzipFile::MAGIC1 and magic2 == Zlib::GzipFile::MAGIC2 then raise Error, 'not in gzip format' end unless method == Zlib::GzipFile::METHOD_DEFLATE then raise Error, "unsupported compression method #{method}" end if flags & Zlib::GzipFile::FLAG_MULTIPART == Zlib::GzipFile::FLAG_MULTIPART then raise Error, 'multi-part gzip file is not supported' end if flags & Zlib::GzipFile::FLAG_ENCRYPT == Zlib::GzipFile::FLAG_ENCRYPT then raise Error, 'encrypted gzip file is not supported' end if flags & Zlib::GzipFile::FLAG_UNKNOWN_MASK == Zlib::GzipFile::FLAG_UNKNOWN_MASK then raise Error, "unknown flags 0x#{flags.to_s 16}" end if extra_flags & Zlib::GzipFile::EXTRAFLAG_FAST == Zlib::GzipFile::EXTRAFLAG_FAST then @level = Zlib::BEST_SPEED elsif extra_flags & Zlib::GzipFile::EXTRAFLAG_SLOW == Zlib::GzipFile::EXTRAFLAG_SLOW then @level = Zlib::BEST_COMPRESSION else @level = Zlib::DEFAULT_COMPRESSION end if flags & Zlib::GzipFile::FLAG_EXTRA == Zlib::GzipFile::FLAG_EXTRA then length = @io.read 2 raise Zlib::GzipFile::Error, 'unexpected end of file' if length.nil? or length.length != 2 length, = length.unpack 'v' extra = @io.read length + 2 raise Zlib::GzipFile::Error, 'unexpected end of file' if extra.nil? or extra.length != length + 2 end if flags & Zlib::GzipFile::FLAG_ORIG_NAME == Zlib::GzipFile::FLAG_ORIG_NAME then @orig_name = '' c = @io.getc until c == 0 do @orig_name << c.chr c = @io.getc end end if flags & Zlib::GzipFile::FLAG_COMMENT == Zlib::GzipFile::FLAG_COMMENT then @comment = '' c = @io.getc until c == 0 do @comment << c.chr c = @io.getc end end end end ## # Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should # be used with an instance of IO, or IO-like, object. # # For example: # # Zlib::GzipWriter.open('hoge.gz') do |gz| # gz.write 'jugemu jugemu gokou no surikire...' # end # # File.open('hoge.gz', 'w') do |f| # gz = Zlib::GzipWriter.new(f) # gz.write 'jugemu jugemu gokou no surikire...' # gz.close # end # # NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close # GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter # will be not able to write the gzip footer and will generate a broken gzip # file. class GzipWriter < GzipFile # HACK use a buffer class ## # Set the comment attr_writer :comment ## # Set the original name attr_writer :orig_name ## # Creates a GzipWriter object associated with +io+. +level+ and +strategy+ # should be the same as the arguments of Zlib::Deflate.new. The # GzipWriter object writes gzipped data to +io+. At least, +io+ must # respond to the +write+ method that behaves same as write method in IO # class. def initialize(io, level = Zlib::DEFAULT_COMPRESSION, strategy = Zlib::DEFAULT_STRATEGY) @io = io @zstream = Zlib::Deflate.new level, -Zlib::MAX_WBITS, Zlib::DEF_MEM_LEVEL, strategy @buffer = '' super() end def end_run make_header unless header_finished? @zstream.run '', Zlib::FINISH write_raw make_footer nil end ## # Flushes all the internal buffers of the GzipWriter object. The meaning # of +flush+ is same as in Zlib::Deflate#deflate. # <tt>Zlib::SYNC_FLUSH</tt> is used if +flush+ is omitted. It is no use # giving flush <tt>Zlib::NO_FLUSH</tt>. def flush true end ## # Writes out a gzip header def make_header flags = 0 extra_flags = 0 flags |= Zlib::GzipFile::FLAG_ORIG_NAME if @orig_name flags |= Zlib::GzipFile::FLAG_COMMENT if @comment extra_flags |= Zlib::GzipFile::EXTRAFLAG_FAST if @level == Zlib::BEST_SPEED extra_flags |= Zlib::GzipFile::EXTRAFLAG_SLOW if @level == Zlib::BEST_COMPRESSION header = [ Zlib::GzipFile::MAGIC1, # byte 0 Zlib::GzipFile::MAGIC2, # byte 1 Zlib::GzipFile::METHOD_DEFLATE, # byte 2 flags, # byte 3 @mtime.to_i, # bytes 4-7 extra_flags, # byte 8 @os_code # byte 9 ].pack 'CCCCVCC' @io.write header @io.write "#{@orig_name}\0" if @orig_name @io.write "#{@comment}\0" if @comment @zstream.flags |= Zlib::GzipFile::HEADER_FINISHED end ## # Writes out a gzip footer def make_footer footer = [ @crc, # bytes 0-3 @zstream.total_in, # bytes 4-7 ].pack 'VV' @io.write footer @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED end ## # Sets the modification time of this file def mtime=(time) if header_finished? then raise Zlib::GzipFile::Error, 'header is already written' end @mtime = Integer time end def sync? @zstream.flags & Zlib::GzipFile::SYNC == Zlib::GzipFile::SYNC end ## # Same as IO. def write(data) make_header unless header_finished? data = String data if data.length > 0 or sync? then @crc = Zlib.crc32_c @crc, data, data.length flush = sync? ? Zlib::SYNC_FLUSH : Zlib::NO_FLUSH @zstream.run data, flush end write_raw end ## # Same as IO. alias << write def write_raw data = @zstream.detatch_output unless data.empty? then @io.write data @io.flush if sync? and io.respond_to :flush end end end ## # Zlib:Inflate is the class for decompressing compressed data. Unlike # Zlib::Deflate, an instance of this class is not able to duplicate (clone, # dup) itself. class Inflate < ZStream ## # Decompresses +string+. Raises a Zlib::NeedDict exception if a preset # dictionary is needed for decompression. # # This method is almost equivalent to the following code: # # def inflate(string) # zstream = Zlib::Inflate.new # buf = zstream.inflate(string) # zstream.finish # zstream.close # buf # end def self.inflate(data) inflator = new unzipped = inflator.inflate data unzipped ensure inflator.end end ## # Creates a new inflate stream for decompression. See zlib.h for details # of the argument. If +window_bits+ is +nil+, the default value is used. def initialize(window_bits = Zlib::MAX_WBITS) super() @func_end = :inflateEnd @func_reset = :inflateReset @func_run = :inflate err = Zlib.inflateInit2 pointer, window_bits Zlib.handle_error err, message # HACK ready end ## # Inputs +string+ into the inflate stream just like Zlib::Inflate#inflate, # but returns the Zlib::Inflate object itself. The output from the stream # is preserved in output buffer. def <<(string) string = StringValue string unless string.nil? if finished? then unless string.nil? then @input ||= '' @input << string end else run string, Zlib::SYNC_FLUSH end end ## # Inputs +string+ into the inflate stream and returns the output from the # stream. Calling this method, both the input and the output buffer of # the stream are flushed. If string is +nil+, this method finishes the
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
true
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/sparc-solaris/sysconf.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/sparc-solaris/sysconf.rb
# This file is generated by rake. Do not edit. module Platform;end module Platform::Sysconf SC_2_CHAR_TERM = 66 SC_2_C_BIND = 45 SC_2_C_DEV = 46 SC_2_FORT_DEV = 48 SC_2_FORT_RUN = 49 SC_2_LOCALEDEF = 50 SC_2_PBS = 724 SC_2_PBS_ACCOUNTING = 725 SC_2_PBS_CHECKPOINT = 726 SC_2_PBS_LOCATE = 728 SC_2_PBS_MESSAGE = 729 SC_2_PBS_TRACK = 730 SC_2_SW_DEV = 51 SC_2_UPE = 52 SC_2_VERSION = 53 SC_ADVISORY_INFO = 731 SC_AIO_LISTIO_MAX = 18 SC_AIO_MAX = 19 SC_AIO_PRIO_DELTA_MAX = 20 SC_ARG_MAX = 1 SC_ASYNCHRONOUS_IO = 21 SC_ATEXIT_MAX = 76 SC_BARRIERS = 732 SC_BC_BASE_MAX = 54 SC_BC_DIM_MAX = 55 SC_BC_SCALE_MAX = 56 SC_BC_STRING_MAX = 57 SC_CHILD_MAX = 2 SC_CLK_TCK = 3 SC_CLOCK_SELECTION = 733 SC_COLL_WEIGHTS_MAX = 58 SC_CPUTIME = 734 SC_DELAYTIMER_MAX = 22 SC_EXPR_NEST_MAX = 59 # _SC_FILE_LOCKING not available SC_FSYNC = 23 SC_GETGR_R_SIZE_MAX = 569 SC_GETPW_R_SIZE_MAX = 570 SC_HOST_NAME_MAX = 735 SC_IOV_MAX = 77 SC_IPV6 = 762 SC_JOB_CONTROL = 6 SC_LINE_MAX = 60 SC_LOGIN_NAME_MAX = 571 SC_MAPPED_FILES = 24 SC_MEMLOCK = 25 SC_MEMLOCK_RANGE = 26 SC_MEMORY_PROTECTION = 27 SC_MESSAGE_PASSING = 28 SC_MONOTONIC_CLOCK = 736 SC_MQ_OPEN_MAX = 29 SC_MQ_PRIO_MAX = 30 SC_NGROUPS_MAX = 4 SC_NPROCESSORS_CONF = 14 SC_NPROCESSORS_ONLN = 15 SC_OPEN_MAX = 5 SC_PAGESIZE = 11 SC_PAGE_SIZE = 11 SC_PASS_MAX = 9 SC_PRIORITIZED_IO = 31 SC_PRIORITY_SCHEDULING = 32 SC_RAW_SOCKETS = 763 SC_READER_WRITER_LOCKS = 737 SC_REALTIME_SIGNALS = 33 SC_REGEXP = 738 SC_RE_DUP_MAX = 61 SC_RTSIG_MAX = 34 SC_SAVED_IDS = 7 SC_SEMAPHORES = 35 SC_SEM_NSEMS_MAX = 36 SC_SEM_VALUE_MAX = 37 SC_SHARED_MEMORY_OBJECTS = 38 SC_SHELL = 739 SC_SIGQUEUE_MAX = 39 SC_SPAWN = 740 SC_SPIN_LOCKS = 741 SC_SPORADIC_SERVER = 742 SC_SS_REPL_MAX = 743 SC_STREAM_MAX = 16 SC_SYMLOOP_MAX = 744 SC_SYNCHRONIZED_IO = 42 SC_THREADS = 576 SC_THREAD_ATTR_STACKADDR = 577 SC_THREAD_ATTR_STACKSIZE = 578 SC_THREAD_CPUTIME = 745 SC_THREAD_DESTRUCTOR_ITERATIONS = 568 SC_THREAD_KEYS_MAX = 572 SC_THREAD_PRIORITY_SCHEDULING = 579 SC_THREAD_PRIO_INHERIT = 580 SC_THREAD_PRIO_PROTECT = 581 SC_THREAD_PROCESS_SHARED = 582 SC_THREAD_SAFE_FUNCTIONS = 583 SC_THREAD_SPORADIC_SERVER = 746 SC_THREAD_STACK_MIN = 573 SC_THREAD_THREADS_MAX = 574 SC_TIMEOUTS = 747 SC_TIMERS = 43 SC_TIMER_MAX = 44 SC_TRACE = 748 SC_TRACE_EVENT_FILTER = 749 SC_TRACE_EVENT_NAME_MAX = 750 SC_TRACE_INHERIT = 751 SC_TRACE_LOG = 752 SC_TRACE_NAME_MAX = 753 SC_TRACE_SYS_MAX = 754 SC_TRACE_USER_EVENT_MAX = 755 SC_TTY_NAME_MAX = 575 SC_TYPED_MEMORY_OBJECTS = 756 SC_TZNAME_MAX = 17 SC_V6_ILP32_OFF32 = 757 SC_V6_ILP32_OFFBIG = 758 SC_V6_LP64_OFF64 = 759 SC_V6_LPBIG_OFFBIG = 760 SC_VERSION = 8 SC_XBS5_ILP32_OFF32 = 720 SC_XBS5_ILP32_OFFBIG = 721 SC_XBS5_LP64_OFF64 = 722 SC_XBS5_LPBIG_OFFBIG = 723 SC_XOPEN_CRYPT = 62 SC_XOPEN_ENH_I18N = 63 SC_XOPEN_LEGACY = 717 SC_XOPEN_REALTIME = 718 SC_XOPEN_REALTIME_THREADS = 719 SC_XOPEN_SHM = 64 SC_XOPEN_STREAMS = 761 SC_XOPEN_UNIX = 78 SC_XOPEN_VERSION = 12 SC_XOPEN_XCU_VERSION = 67 end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/sparcv9-solaris/errno.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/sparcv9-solaris/errno.rb
# This file is generated by rake. Do not edit. module Platform; end module Platform::Errno E2BIG = 7 EACCES = 13 EADDRINUSE = 125 EADDRNOTAVAIL = 126 EAFNOSUPPORT = 124 EAGAIN = 11 EALREADY = 149 EBADF = 9 EBUSY = 16 ECHILD = 10 ECONNABORTED = 130 ECONNREFUSED = 146 ECONNRESET = 131 EDEADLK = 45 EDESTADDRREQ = 96 EEXIST = 17 EFAULT = 14 EFBIG = 27 EHOSTDOWN = 147 EHOSTUNREACH = 148 EINPROGRESS = 150 EINTR = 4 EINVAL = 22 EIO = 5 EISCONN = 133 EISDIR = 21 ELOOP = 90 EMFILE = 24 EMLINK = 31 EMSGSIZE = 97 ENAMETOOLONG = 78 ENETDOWN = 127 ENETRESET = 129 ENETUNREACH = 128 ENFILE = 23 ENOBUFS = 132 ENODEV = 19 ENOENT = 2 ENOEXEC = 8 ENOMEM = 12 ENOPROTOOPT = 99 ENOSPC = 28 ENOTCONN = 134 ENOTDIR = 20 ENOTEMPTY = 93 ENOTSOCK = 95 ENOTTY = 25 ENXIO = 6 EOPNOTSUPP = 122 EPERM = 1 EPIPE = 32 EPROTONOSUPPORT = 120 EPROTOTYPE = 98 EROFS = 30 ESPIPE = 29 ESRCH = 3 ETIMEDOUT = 145 ETXTBSY = 26 EWOULDBLOCK = 11 EXDEV = 18 end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/sparcv9-solaris/socket.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/sparcv9-solaris/socket.rb
# This file is generated by rake. Do not edit. module Platform; end module Platform::Socket AF_APPLETALK = 16 # AF_ATM not available # AF_AX25 not available AF_CCITT = 10 AF_CHAOS = 5 # AF_CNT not available # AF_COIP not available AF_DATAKIT = 9 AF_DECnet = 12 AF_DLI = 13 # AF_E164 not available AF_ECMA = 8 AF_HYLINK = 15 AF_IMPLINK = 3 AF_INET = 2 AF_INET6 = 26 AF_IPX = 23 # AF_ISDN not available # AF_ISO not available AF_LAT = 14 AF_LINK = 25 # AF_LOCAL not available AF_MAX = 29 # AF_NATM not available # AF_NDRV not available # AF_NETBIOS not available # AF_NETGRAPH not available AF_NS = 6 AF_OSI = 19 # AF_PPP not available AF_PUP = 4 AF_ROUTE = 24 # AF_SIP not available AF_SNA = 11 # AF_SYSTEM not available AF_UNIX = 1 AF_UNSPEC = 0 NI_DGRAM = 16 # NI_FQDN_FLAG_VALIDTTL not available NI_MAXHOST = 1025 NI_MAXSERV = 32 NI_NAMEREQD = 4 # NI_NODEADDR_FLAG_ALL not available # NI_NODEADDR_FLAG_ANYCAST not available # NI_NODEADDR_FLAG_COMPAT not available # NI_NODEADDR_FLAG_GLOBAL not available # NI_NODEADDR_FLAG_LINKLOCAL not available # NI_NODEADDR_FLAG_SITELOCAL not available # NI_NODEADDR_FLAG_TRUNCATE not available NI_NOFQDN = 1 NI_NUMERICHOST = 2 NI_NUMERICSERV = 8 # NI_QTYPE_DNSNAME not available # NI_QTYPE_FQDN not available # NI_QTYPE_IPV4ADDR not available # NI_QTYPE_NODEADDR not available # NI_QTYPE_NOOP not available # NI_QTYPE_SUPTYPES not available # NI_SUPTYPE_FLAG_COMPRESS not available NI_WITHSCOPEID = 32 PF_APPLETALK = 16 # PF_ATM not available PF_CCITT = 10 PF_CHAOS = 5 # PF_CNT not available # PF_COIP not available PF_DATAKIT = 9 PF_DECnet = 12 PF_DLI = 13 PF_ECMA = 8 PF_HYLINK = 15 PF_IMPLINK = 3 PF_INET = 2 PF_INET6 = 26 PF_IPX = 23 # PF_ISDN not available # PF_ISO not available PF_KEY = 27 PF_LAT = 14 PF_LINK = 25 # PF_LOCAL not available PF_MAX = 29 # PF_NATM not available # PF_NDRV not available # PF_NETBIOS not available # PF_NETGRAPH not available PF_NS = 6 PF_OSI = 19 # PF_PIP not available # PF_PPP not available PF_PUP = 4 PF_ROUTE = 24 # PF_RTIP not available # PF_SIP not available PF_SNA = 11 # PF_SYSTEM not available PF_UNIX = 1 PF_UNSPEC = 0 # PF_XTP not available SOCK_DGRAM = 1 # SOCK_MAXADDRLEN not available SOCK_RAW = 4 SOCK_RDM = 5 SOCK_SEQPACKET = 6 SOCK_STREAM = 2 SO_ACCEPTCONN = 2 # SO_ACCEPTFILTER not available # SO_ATTACH_FILTER not available # SO_BINDTODEVICE not available SO_BROADCAST = 32 SO_DEBUG = 1 # SO_DETACH_FILTER not available SO_DONTROUTE = 16 # SO_DONTTRUNC not available SO_ERROR = 4103 SO_KEEPALIVE = 8 # SO_LABEL not available SO_LINGER = 128 # SO_NKE not available # SO_NOADDRERR not available # SO_NOSIGPIPE not available # SO_NO_CHECK not available # SO_NREAD not available # SO_NWRITE not available SO_OOBINLINE = 256 # SO_PASSCRED not available # SO_PEERCRED not available # SO_PEERLABEL not available # SO_PEERNAME not available # SO_PRIORITY not available SO_RCVBUF = 4098 SO_RCVLOWAT = 4100 SO_RCVTIMEO = 4102 SO_REUSEADDR = 4 # SO_REUSEPORT not available # SO_REUSESHAREUID not available # SO_SECURITY_AUTHENTICATION not available # SO_SECURITY_ENCRYPTION_NETWORK not available # SO_SECURITY_ENCRYPTION_TRANSPORT not available SO_SNDBUF = 4097 SO_SNDLOWAT = 4099 SO_SNDTIMEO = 4101 # SO_TIMESTAMP not available SO_TYPE = 4104 SO_USELOOPBACK = 64 # SO_WANTMORE not available # SO_WANTOOBFLAG not available # pseudo_AF_HDRCMPLT not available # pseudo_AF_KEY not available # pseudo_AF_PIP not available # pseudo_AF_RTIP not available # pseudo_AF_XTP not available end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/sparcv9-solaris/stat.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/sparcv9-solaris/stat.rb
# This file is generated by rake. Do not edit. module Platform module Stat class Stat < FFI::Struct self.size = 152 layout :st_dev, :dev_t, 0, :st_ino, :ino_t, 16, :st_nlink, :nlink_t, 28, :st_mode, :mode_t, 24, :st_uid, :uid_t, 32, :st_gid, :gid_t, 36, :st_size, :off_t, 56, :st_blocks, :blkcnt_t, 96, :st_atime, :time_t, 64, :st_mtime, :time_t, 72, :st_ctime, :time_t, 80 end module Constants S_IEXEC = 0x40 S_IREAD = 0x100 S_IRGRP = 0x20 S_IROTH = 0x4 S_IRUSR = 0x100 S_IRWXG = 0x38 S_IRWXO = 0x7 S_IRWXU = 0x1c0 S_ISGID = 0x400 S_ISUID = 0x800 S_IWGRP = 0x10 S_IWOTH = 0x2 S_IWRITE = 0x80 S_IWUSR = 0x80 S_IXGRP = 0x8 S_IXOTH = 0x1 S_IXUSR = 0x40 end include Constants end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/sparcv9-solaris/etc.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/sparcv9-solaris/etc.rb
# This file is generated by rake. Do not edit. module Platform; end module Platform::Etc class Passwd < FFI::Struct self.size = 36 layout :pw_name, :string, 0, :pw_passwd, :string, 4, :pw_uid, :uint, 8, :pw_gid, :uint, 12, :pw_dir, :string, 28, :pw_shell, :string, 32 end class Group < FFI::Struct self.size = 16 layout :gr_name, :string, 0, :gr_gid, :uint, 8 end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/sparcv9-solaris/syslog.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/sparcv9-solaris/syslog.rb
# This file is generated by rake. Do not edit. module Syslog module Constants LOG_ALERT = 1 LOG_AUTH = 32 # LOG_AUTHPRIV not available LOG_CONS = 2 # LOG_CONSOLE not available LOG_CRIT = 2 LOG_CRON = 120 LOG_DAEMON = 24 LOG_DEBUG = 7 LOG_EMERG = 0 LOG_ERR = 3 # LOG_FTP not available LOG_INFO = 6 LOG_KERN = 0 LOG_LOCAL0 = 128 LOG_LOCAL1 = 136 LOG_LOCAL2 = 144 LOG_LOCAL3 = 152 LOG_LOCAL4 = 160 LOG_LOCAL5 = 168 LOG_LOCAL6 = 176 LOG_LOCAL7 = 184 LOG_LPR = 48 LOG_MAIL = 16 LOG_NEWS = 56 # LOG_NODELAY not available LOG_NOTICE = 5 LOG_NOWAIT = 16 # LOG_NTP not available LOG_ODELAY = 4 # LOG_PERROR not available LOG_PID = 1 # LOG_SECURITY not available LOG_SYSLOG = 40 LOG_USER = 8 LOG_UUCP = 64 LOG_WARNING = 4 end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/sparcv9-solaris/fcntl.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/sparcv9-solaris/fcntl.rb
# This file is generated by rake. Do not edit. module Fcntl FD_CLOEXEC = 1 F_DUPFD = 0 F_GETFD = 1 F_GETFL = 3 F_GETLK = 33 F_RDLCK = 1 F_SETFD = 2 F_SETFL = 4 F_SETLK = 34 F_SETLKW = 35 F_UNLCK = 3 F_WRLCK = 2 O_ACCMODE = 3 O_APPEND = 8 O_CREAT = 256 O_EXCL = 1024 O_NDELAY = 4 O_NOCTTY = 2048 O_NONBLOCK = 128 O_RDONLY = 0 O_RDWR = 2 O_TRUNC = 512 O_WRONLY = 1 end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/sparcv9-solaris/zlib.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/sparcv9-solaris/zlib.rb
# This file is generated by rake. Do not edit. ## # The Zlib module contains several classes for compressing and decompressing # streams, and for working with "gzip" files. # # == Classes # # Following are the classes that are most likely to be of interest to the # user: # - Zlib::Inflate # - Zlib::Deflate # - Zlib::GzipReader # - Zlib::GzipWriter # # There are two important base classes for the classes above: Zlib::ZStream # and Zlib::GzipFile. Everything else is an error class. # # == Constants # # Here's a list. # # Zlib::VERSION # The Ruby/zlib version string. # # Zlib::ZLIB_VERSION # The string which represents the version of zlib.h. # # Zlib::BINARY # Zlib::ASCII # Zlib::UNKNOWN # The integers representing data types which Zlib::ZStream#data_type # method returns. # # Zlib::NO_COMPRESSION # Zlib::BEST_SPEED # Zlib::BEST_COMPRESSION # Zlib::DEFAULT_COMPRESSION # The integers representing compression levels which are an argument # for Zlib::Deflate.new, Zlib::Deflate#deflate, and so on. # # Zlib::FILTERED # Zlib::HUFFMAN_ONLY # Zlib::DEFAULT_STRATEGY # The integers representing compression methods which are an argument # for Zlib::Deflate.new and Zlib::Deflate#params. # # Zlib::DEF_MEM_LEVEL # Zlib::MAX_MEM_LEVEL # The integers representing memory levels which are an argument for # Zlib::Deflate.new, Zlib::Deflate#params, and so on. # # Zlib::MAX_WBITS # The default value of windowBits which is an argument for # Zlib::Deflate.new and Zlib::Inflate.new. # # Zlib::NO_FLUSH # Zlib::SYNC_FLUSH # Zlib::FULL_FLUSH # Zlib::FINISH # The integers to control the output of the deflate stream, which are # an argument for Zlib::Deflate#deflate and so on. #-- # These constants are missing! # # Zlib::OS_CODE # Zlib::OS_MSDOS # Zlib::OS_AMIGA # Zlib::OS_VMS # Zlib::OS_UNIX # Zlib::OS_VMCMS # Zlib::OS_ATARI # Zlib::OS_OS2 # Zlib::OS_MACOS # Zlib::OS_ZSYSTEM # Zlib::OS_CPM # Zlib::OS_TOPS20 # Zlib::OS_WIN32 # Zlib::OS_QDOS # Zlib::OS_RISCOS # Zlib::OS_UNKNOWN # The return values of Zlib::GzipFile#os_code method. module Zlib ZLIB_VERSION = "1.2.3" BEST_COMPRESSION = 9 BEST_SPEED = 1 BLOCK = 5 BUF_ERROR = -5 DATA_ERROR = -3 DEFAULT_COMPRESSION = -1 DEFAULT_STRATEGY = 0 DEFLATED = 8 ERRNO = -1 FILTERED = 1 FINISH = 4 FIXED = 4 FULL_FLUSH = 3 HUFFMAN_ONLY = 2 MEM_ERROR = -4 NEED_DICT = 2 NO_COMPRESSION = 0 NO_FLUSH = 0 OK = 0 PARTIAL_FLUSH = 1 RLE = 3 STREAM_END = 1 STREAM_ERROR = -2 SYNC_FLUSH = 2 VERSION_ERROR = -6 # DEF_MEM_LEVEL not available MAX_MEM_LEVEL = 9 MAX_WBITS = 15 OS_MSDOS = 0x00 OS_AMIGA = 0x01 OS_VMS = 0x02 OS_UNIX = 0x03 OS_ATARI = 0x05 OS_OS2 = 0x06 OS_MACOS = 0x07 OS_TOPS20 = 0x0a OS_WIN32 = 0x0b OS_VMCMS = 0x04 OS_ZSYSTEM = 0x08 OS_CPM = 0x09 OS_QDOS = 0x0c OS_RISCOS = 0x0d OS_UNKNOWN = 0xff # OS_CODE not available unless defined? OS_CODE then OS_CODE = OS_UNIX end # from zutil.h unless defined? DEF_MEM_LEVEL then DEF_MEM_LEVEL = MAX_MEM_LEVEL >= 8 ? 8 : MAX_MEM_LEVEL end class Error < StandardError; end class StreamEnd < Error; end class NeedDict < Error; end class StreamError < Error; end class DataError < Error; end class BufError < Error; end class VersionError < Error; end class MemError < Error; end ## # Zlib::ZStream is the abstract class for the stream which handles the # compressed data. The operations are defined in the subclasses: # Zlib::Deflate for compression, and Zlib::Inflate for decompression. # # An instance of Zlib::ZStream has one stream (struct zstream in the source) # and two variable-length buffers which associated to the input (next_in) of # the stream and the output (next_out) of the stream. In this document, # "input buffer" means the buffer for input, and "output buffer" means the # buffer for output. # # Data input into an instance of Zlib::ZStream are temporally stored into # the end of input buffer, and then data in input buffer are processed from # the beginning of the buffer until no more output from the stream is # produced (i.e. until avail_out > 0 after processing). During processing, # output buffer is allocated and expanded automatically to hold all output # data. # # Some particular instance methods consume the data in output buffer and # return them as a String. # # Here is an ascii art for describing above: # # +================ an instance of Zlib::ZStream ================+ # || || # || +--------+ +-------+ +--------+ || # || +--| output |<---------|zstream|<---------| input |<--+ || # || | | buffer | next_out+-------+next_in | buffer | | || # || | +--------+ +--------+ | || # || | | || # +===|======================================================|===+ # | | # v | # "output data" "input data" # # If an error occurs during processing input buffer, an exception which is a # subclass of Zlib::Error is raised. At that time, both input and output # buffer keep their conditions at the time when the error occurs. # # == Method Catalogue # # Many of the methods in this class are fairly low-level and unlikely to be # of interest to users. In fact, users are unlikely to use this class # directly; rather they will be interested in Zlib::Inflate and # Zlib::Deflate. # # The higher level methods are listed below. # # - #total_in # - #total_out # - #data_type # - #adler # - #reset # - #finish # - #finished? # - #close # - #closed? class ZStream < FFI::Struct self.size = 56 layout :next_in, :pointer, 0, :avail_in, :uint, 4, :total_in, :ulong, 8, :next_out, :pointer, 12, :avail_out, :uint, 16, :total_out, :ulong, 20, :msg, :string, 24, :state, :pointer, 28, :zalloc, :pointer, 32, :zfree, :pointer, 36, :opaque, :pointer, 40, :data_type, :int, 44, :adler, :ulong, 48, :reserved, :ulong, 52 #-- # HACK from MRI's zlib.c #++ READY = 0x1 IN_STREAM = 0x2 FINISHED = 0x4 CLOSING = 0x8 UNUSED = 0x10 attr_accessor :flags attr_reader :input attr_reader :output def self.inherited(subclass) subclass.instance_variable_set :@layout, @layout subclass.instance_variable_set :@size, @size end def initialize super self[:avail_in] = 0 self[:avail_out] = 0 self[:next_in] = nil self[:opaque] = nil self[:zalloc] = nil self[:zfree] = nil reset_input @output = nil @flags = 0 @func = nil end def closing? @flags & CLOSING == CLOSING end def detatch_output if @output.nil? then data = '' else data = @output @output = nil self[:avail_out] = 0 self[:next_out] = nil end data end ## # Closes the stream. All operations on the closed stream will raise an # exception. def end unless ready? then warn "attempt to close uninitialized stream; ignored." return nil end if in_stream? then warn "attempt to close unfinished zstream; reset forced" reset end reset_input err = Zlib.send @func_end, pointer Zlib.handle_error err, message @flags = 0 # HACK this may be wrong @output = nil @next_out.free unless @next_out.nil? @next_out = nil nil end alias :close :end def expand_output if @output.nil? then @output = '' @next_out = MemoryPointer.new CHUNK if @next_out.nil? @next_out.write_string "\000" * CHUNK self[:next_out] = @next_out else have = CHUNK - self[:avail_out] @output << @next_out.read_string(have) self[:next_out] = @next_out # Zlib advances self[:next_out] end self[:avail_out] = CHUNK end ## # Finishes the stream and flushes output buffer. See Zlib::Deflate#finish # and Zlib::Inflate#finish for details of this behavior. def finish run '', Zlib::FINISH detatch_output end ## # Returns true if the stream is finished. def finished? @flags & FINISHED == FINISHED end ## # Flushes output buffer and returns all data in that buffer. def flush_next_out detatch_output end def in_stream? @flags & IN_STREAM == IN_STREAM end def input_empty? @input.nil? or @input.empty? end ## # The msg field of the struct def message self[:msg] end def ready @flags |= READY end def ready? @flags & READY == READY end ## # Resets and initializes the stream. All data in both input and output # buffer are discarded. def reset err = Zlib.send @func_reset, pointer Zlib.handle_error err, message @flags = READY reset_input end def reset_input @input = nil end def run(data, flush) if @input.nil? and data.empty? then data_in = MemoryPointer.new 1 data_in.write_string "\000", 1 self[:next_in] = data_in self[:avail_in] = 0 else @input ||= '' @input << data data_in = MemoryPointer.new @input.length data_in.write_string @input, @input.length self[:next_in] = data_in self[:avail_in] = @input.length end expand_output if self[:avail_out] == 0 loop do err = Zlib.send @func_run, pointer, flush available = self[:avail_out] expand_output # HACK does this work when err is set? if err == Zlib::STREAM_END then @flags &= ~IN_STREAM @flags |= FINISHED break end unless err == Zlib::OK then if flush != Zlib::FINISH and err == Zlib::BUF_ERROR and self[:avail_out] > 0 then @flags |= IN_STREAM break end if self[:avail_in] > 0 then @input = self[:next_in].read_string(self[:avail_in]) + @input end Zlib.handle_error err, message end if available > 0 then @flags |= IN_STREAM break end end reset_input if self[:avail_in] > 0 then @input = self[:next_in].read_string self[:avail_in] end ensure data_in.free self[:next_in] = nil end ## # Returns the number of bytes consumed def total_in self[:total_in] end ## # Returns the number bytes processed def total_out self[:total_out] end end set_ffi_lib 'libz' # deflateInit2 is a macro pointing to deflateInit2_ attach_function :deflateInit2_, [ :pointer, # z_streamp strm :int, # int level :int, # int method :int, # int windowBits :int, # int memLevel :int, # int strategy :string, # ZLIB_VERSION :int # (int)sizeof(z_stream) ], :int def self.deflateInit2(stream, level, method, window_bits, mem_level, strategy) deflateInit2_ stream, level, method, window_bits, mem_level, strategy, ZLIB_VERSION, ZStream.size end attach_function :deflate, [:pointer, :int], :int attach_function :deflateEnd, [:pointer], :int attach_function :deflateParams, [:pointer, :int, :int], :int attach_function :deflateReset, [:pointer], :int attach_function :deflateSetDictionary, [:pointer, :string, :uint], :int # inflateInit2 is a macro pointing to inflateInit2_ attach_function :inflateInit2_, [:pointer, :int, :string, :int], :int def self.inflateInit2(stream, window_bits) inflateInit2_ stream, window_bits, ZLIB_VERSION, ZStream.size end attach_function :inflate, [:pointer, :int], :int attach_function :inflateEnd, [:pointer], :int attach_function :inflateReset, [:pointer], :int attach_function :inflateSetDictionary, [:pointer, :string, :uint], :int attach_function :adler32_c, :adler32, [:ulong, :string, :uint], :ulong attach_function :crc32_c, :crc32, [:ulong, :string, :uint], :ulong attach_function :get_crc_table_c, :get_crc_table, [], :pointer attach_function :zError, [:int], :string # Chunk size for inflation and deflation CHUNK = 1024 #-- # HACK from zlib.c #++ GZ_EXTRAFLAG_FAST = 0x4 GZ_EXTRAFLAG_SLOW = 0x2 ## # Zlib::Deflate is the class for compressing data. See Zlib::ZStream for # more information. class Deflate < ZStream ## # Compresses the given +string+. Valid values of level are # <tt>Zlib::NO_COMPRESSION</tt>, <tt>Zlib::BEST_SPEED</tt>, # <tt>Zlib::BEST_COMPRESSION</tt>, <tt>Zlib::DEFAULT_COMPRESSION</tt>, and # an integer from 0 to 9. # # This method is almost equivalent to the following code: # # def deflate(string, level) # z = Zlib::Deflate.new(level) # dst = z.deflate(string, Zlib::FINISH) # z.close # dst # end def self.deflate(data, level = Zlib::DEFAULT_COMPRESSION) deflator = new level zipped = deflator.deflate data, Zlib::FINISH zipped ensure deflator.end end ## # Creates a new deflate stream for compression. See zlib.h for details of # each argument. If an argument is nil, the default value of that argument # is used. def initialize(level = Zlib::DEFAULT_COMPRESSION, window_bits = Zlib::MAX_WBITS, mem_level = Zlib::DEF_MEM_LEVEL, strategy = Zlib::DEFAULT_STRATEGY) level ||= Zlib::DEFAULT_COMPRESSION window_bits ||= Zlib::MAX_WBITS mem_level ||= Zlib::DEF_MEM_LEVEL strategy ||= Zlib::DEFAULT_STRATEGY super() @func_end = :deflateEnd @func_reset = :deflateReset @func_run = :deflate err = Zlib.deflateInit2(pointer, level, Zlib::DEFLATED, window_bits, mem_level, strategy) Zlib.handle_error err, message ready end ## # Same as IO. def <<(data) do_deflate data, Zlib::NO_FLUSH self end ## # Inputs +string+ into the deflate stream and returns the output from the # stream. On calling this method, both the input and the output buffers # of the stream are flushed. If +string+ is nil, this method finishes the # stream, just like Zlib::ZStream#finish. # # The value of +flush+ should be either <tt>Zlib::NO_FLUSH</tt>, # <tt>Zlib::SYNC_FLUSH</tt>, <tt>Zlib::FULL_FLUSH</tt>, or # <tt>Zlib::FINISH</tt>. See zlib.h for details. def deflate(data, flush = Zlib::NO_FLUSH) do_deflate data, flush detatch_output end ## # Performs the deflate operation and leaves the compressed data in the # output buffer def do_deflate(data, flush) if data.nil? then run '', Zlib::FINISH else data = StringValue data if flush != Zlib::NO_FLUSH or not data.empty? then # prevent BUF_ERROR run data, flush end end end ## # Finishes compressing the deflate input stream and returns the output # buffer. def finish run '', Zlib::FINISH detatch_output end ## # This method is equivalent to <tt>deflate('', flush)</tt>. If flush is # omitted, <tt>Zlib::SYNC_FLUSH</tt> is used as flush. This method is # just provided to improve the readability of your Ruby program. def flush(flush = Zlib::SYNC_FLUSH) run '', flush unless flush == Zlib::NO_FLUSH detatch_output end ## # Changes the parameters of the deflate stream. See zlib.h for details. # The output from the stream by changing the params is preserved in output # buffer. def params(level, strategy) err = Zlib.deflateParams pointer, level, strategy raise Zlib::BufError, 'buffer expansion not implemented' if err == Zlib::BUF_ERROR Zlib.handle_error err, message nil end ## # Sets the preset dictionary and returns +dictionary+. This method is # available just only after Zlib::Deflate.new or Zlib::ZStream#reset # method was called. See zlib.h for details. def set_dictionary(dictionary) dict = StringValue dictionary err = Zlib.deflateSetDictionary pointer, dict, dict.length Zlib.handle_error err, message dictionary end end ## # Zlib::GzipFile is an abstract class for handling a gzip formatted # compressed file. The operations are defined in the subclasses, # Zlib::GzipReader for reading, and Zlib::GzipWriter for writing. # # GzipReader should be used by associating an IO, or IO-like, object. class GzipFile SYNC = Zlib::ZStream::UNUSED HEADER_FINISHED = Zlib::ZStream::UNUSED << 1 FOOTER_FINISHED = Zlib::ZStream::UNUSED << 2 FLAG_MULTIPART = 0x2 FLAG_EXTRA = 0x4 FLAG_ORIG_NAME = 0x8 FLAG_COMMENT = 0x10 FLAG_ENCRYPT = 0x20 FLAG_UNKNOWN_MASK = 0xc0 EXTRAFLAG_FAST = 0x4 EXTRAFLAG_SLOW = 0x2 MAGIC1 = 0x1f MAGIC2 = 0x8b METHOD_DEFLATE = 8 ## # Base class of errors that occur when processing GZIP files. class Error < Zlib::Error; end ## # Raised when gzip file footer is not found. class NoFooter < Error; end ## # Raised when the CRC checksum recorded in gzip file footer is not # equivalent to the CRC checksum of the actual uncompressed data. class CRCError < Error; end ## # Raised when the data length recorded in the gzip file footer is not # equivalent to the length of the actual uncompressed data. class LengthError < Error; end ## # Accessor for the underlying ZStream attr_reader :zstream # :nodoc: ## # See Zlib::GzipReader#wrap and Zlib::GzipWriter#wrap. def self.wrap(*args) obj = new(*args) if block_given? then begin yield obj ensure obj.close if obj.zstream.ready? end end end def initialize @comment = nil @crc = 0 @level = nil @mtime = Time.at 0 @orig_name = nil @os_code = Zlib::OS_CODE end ## # Closes the GzipFile object. This method calls close method of the # associated IO object. Returns the associated IO object. def close io = finish io.close if io.respond_to? :close io end ## # Same as IO def closed? @io.nil? end ## # Returns comments recorded in the gzip file header, or nil if the # comment is not present. def comment raise Error, 'closed gzip stream' if @io.nil? @comment.dup end def end return if @zstream.closing? @zstream.flags |= Zlib::ZStream::CLOSING begin end_run ensure @zstream.end end end ## # Closes the GzipFile object. Unlike Zlib::GzipFile#close, this method # never calls the close method of the associated IO object. Returns the # associated IO object. def finish self.end io = @io @io = nil @orig_name = nil @comment = nil io end def finished? @zstream.finished? and @zstream.output.empty? # HACK I think end def footer_finished? @zstream.flags & Zlib::GzipFile::FOOTER_FINISHED == Zlib::GzipFile::FOOTER_FINISHED end def header_finished? @zstream.flags & Zlib::GzipFile::HEADER_FINISHED == Zlib::GzipFile::HEADER_FINISHED end ## # Returns last modification time recorded in the gzip file header. def mtime Time.at @mtime end ## # Returns original filename recorded in the gzip file header, or +nil+ if # original filename is not present. def orig_name raise Error, 'closed gzip stream' if @io.nil? @orig_name.dup end end ## # Zlib::GzipReader is the class for reading a gzipped file. GzipReader # should be used an IO, or -IO-lie, object. # # Zlib::GzipReader.open('hoge.gz') {|gz| # print gz.read # } # # File.open('hoge.gz') do |f| # gz = Zlib::GzipReader.new(f) # print gz.read # gz.close # end # # == Method Catalogue # # The following methods in Zlib::GzipReader are just like their counterparts # in IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an # error was found in the gzip file. # # - #each # - #each_line # - #each_byte # - #gets # - #getc # - #lineno # - #lineno= # - #read # - #readchar # - #readline # - #readlines # - #ungetc # # Be careful of the footer of the gzip file. A gzip file has the checksum of # pre-compressed data in its footer. GzipReader checks all uncompressed data # against that checksum at the following cases, and if it fails, raises # <tt>Zlib::GzipFile::NoFooter</tt>, <tt>Zlib::GzipFile::CRCError</tt>, or # <tt>Zlib::GzipFile::LengthError</tt> exception. # # - When an reading request is received beyond the end of file (the end of # compressed data). That is, when Zlib::GzipReader#read, # Zlib::GzipReader#gets, or some other methods for reading returns nil. # - When Zlib::GzipFile#close method is called after the object reaches the # end of file. # - When Zlib::GzipReader#unused method is called after the object reaches # the end of file. # # The rest of the methods are adequately described in their own # documentation. class GzipReader < GzipFile # HACK use a buffer class ## # Creates a GzipReader object associated with +io+. The GzipReader object # reads gzipped data from +io+, and parses/decompresses them. At least, # +io+ must have a +read+ method that behaves same as the +read+ method in # IO class. # # If the gzip file header is incorrect, raises an Zlib::GzipFile::Error # exception. def initialize(io) @io = io @zstream = Zlib::Inflate.new -Zlib::MAX_WBITS @buffer = '' super() read_header end def check_footer @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED footer = @zstream.input.slice! 0, 8 rest = @io.read 8 - footer.length footer << rest if rest raise NoFooter, 'footer is not found' unless footer.length == 8 crc, length = footer.unpack 'VV' @zstream[:total_in] += 8 # to rewind correctly raise CRCError, 'invalid compressed data -- crc error' unless @crc == crc raise LengthError, 'invalid compressed data -- length error' unless length == @zstream.total_out end def end_run check_footer if @zstream.finished? and not footer_finished? end def eof? @zstream.finished? and @zstream.input_empty? end def pos @zstream[:total_out] - @buffer.length end ## # See Zlib::GzipReader documentation for a description. def read(length = nil) data = @buffer while chunk = @io.read(CHUNK) do inflated = @zstream.inflate(chunk) @crc = Zlib.crc32 inflated, @crc data << inflated break if length and data.length > length end if length then @buffer = data.slice! length..-1 else @buffer = '' end check_footer if @zstream.finished? and not footer_finished? data rescue Zlib::Error => e raise GzipFile::Error, e.message end def read_header header = @io.read 10 raise Error, 'not in gzip format' unless header.length == 10 magic1, magic2, method, flags, @mtime, extra_flags, @os_code = header.unpack 'CCCCVCC' unless magic1 == Zlib::GzipFile::MAGIC1 and magic2 == Zlib::GzipFile::MAGIC2 then raise Error, 'not in gzip format' end unless method == Zlib::GzipFile::METHOD_DEFLATE then raise Error, "unsupported compression method #{method}" end if flags & Zlib::GzipFile::FLAG_MULTIPART == Zlib::GzipFile::FLAG_MULTIPART then raise Error, 'multi-part gzip file is not supported' end if flags & Zlib::GzipFile::FLAG_ENCRYPT == Zlib::GzipFile::FLAG_ENCRYPT then raise Error, 'encrypted gzip file is not supported' end if flags & Zlib::GzipFile::FLAG_UNKNOWN_MASK == Zlib::GzipFile::FLAG_UNKNOWN_MASK then raise Error, "unknown flags 0x#{flags.to_s 16}" end if extra_flags & Zlib::GzipFile::EXTRAFLAG_FAST == Zlib::GzipFile::EXTRAFLAG_FAST then @level = Zlib::BEST_SPEED elsif extra_flags & Zlib::GzipFile::EXTRAFLAG_SLOW == Zlib::GzipFile::EXTRAFLAG_SLOW then @level = Zlib::BEST_COMPRESSION else @level = Zlib::DEFAULT_COMPRESSION end if flags & Zlib::GzipFile::FLAG_EXTRA == Zlib::GzipFile::FLAG_EXTRA then length = @io.read 2 raise Zlib::GzipFile::Error, 'unexpected end of file' if length.nil? or length.length != 2 length, = length.unpack 'v' extra = @io.read length + 2 raise Zlib::GzipFile::Error, 'unexpected end of file' if extra.nil? or extra.length != length + 2 end if flags & Zlib::GzipFile::FLAG_ORIG_NAME == Zlib::GzipFile::FLAG_ORIG_NAME then @orig_name = '' c = @io.getc until c == 0 do @orig_name << c.chr c = @io.getc end end if flags & Zlib::GzipFile::FLAG_COMMENT == Zlib::GzipFile::FLAG_COMMENT then @comment = '' c = @io.getc until c == 0 do @comment << c.chr c = @io.getc end end end end ## # Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should # be used with an instance of IO, or IO-like, object. # # For example: # # Zlib::GzipWriter.open('hoge.gz') do |gz| # gz.write 'jugemu jugemu gokou no surikire...' # end # # File.open('hoge.gz', 'w') do |f| # gz = Zlib::GzipWriter.new(f) # gz.write 'jugemu jugemu gokou no surikire...' # gz.close # end # # NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close # GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter # will be not able to write the gzip footer and will generate a broken gzip # file. class GzipWriter < GzipFile # HACK use a buffer class ## # Set the comment attr_writer :comment ## # Set the original name attr_writer :orig_name ## # Creates a GzipWriter object associated with +io+. +level+ and +strategy+ # should be the same as the arguments of Zlib::Deflate.new. The # GzipWriter object writes gzipped data to +io+. At least, +io+ must # respond to the +write+ method that behaves same as write method in IO # class. def initialize(io, level = Zlib::DEFAULT_COMPRESSION, strategy = Zlib::DEFAULT_STRATEGY) @io = io @zstream = Zlib::Deflate.new level, -Zlib::MAX_WBITS, Zlib::DEF_MEM_LEVEL, strategy @buffer = '' super() end def end_run make_header unless header_finished? @zstream.run '', Zlib::FINISH write_raw make_footer nil end ## # Flushes all the internal buffers of the GzipWriter object. The meaning # of +flush+ is same as in Zlib::Deflate#deflate. # <tt>Zlib::SYNC_FLUSH</tt> is used if +flush+ is omitted. It is no use # giving flush <tt>Zlib::NO_FLUSH</tt>. def flush true end ## # Writes out a gzip header def make_header flags = 0 extra_flags = 0 flags |= Zlib::GzipFile::FLAG_ORIG_NAME if @orig_name flags |= Zlib::GzipFile::FLAG_COMMENT if @comment extra_flags |= Zlib::GzipFile::EXTRAFLAG_FAST if @level == Zlib::BEST_SPEED extra_flags |= Zlib::GzipFile::EXTRAFLAG_SLOW if @level == Zlib::BEST_COMPRESSION header = [ Zlib::GzipFile::MAGIC1, # byte 0 Zlib::GzipFile::MAGIC2, # byte 1 Zlib::GzipFile::METHOD_DEFLATE, # byte 2 flags, # byte 3 @mtime.to_i, # bytes 4-7 extra_flags, # byte 8 @os_code # byte 9 ].pack 'CCCCVCC' @io.write header @io.write "#{@orig_name}\0" if @orig_name @io.write "#{@comment}\0" if @comment @zstream.flags |= Zlib::GzipFile::HEADER_FINISHED end ## # Writes out a gzip footer def make_footer footer = [ @crc, # bytes 0-3 @zstream.total_in, # bytes 4-7 ].pack 'VV' @io.write footer @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED end ## # Sets the modification time of this file def mtime=(time) if header_finished? then raise Zlib::GzipFile::Error, 'header is already written' end @mtime = Integer time end def sync? @zstream.flags & Zlib::GzipFile::SYNC == Zlib::GzipFile::SYNC end ## # Same as IO. def write(data) make_header unless header_finished? data = String data if data.length > 0 or sync? then @crc = Zlib.crc32_c @crc, data, data.length flush = sync? ? Zlib::SYNC_FLUSH : Zlib::NO_FLUSH @zstream.run data, flush end write_raw end ## # Same as IO. alias << write def write_raw data = @zstream.detatch_output unless data.empty? then @io.write data @io.flush if sync? and io.respond_to :flush end end end ## # Zlib:Inflate is the class for decompressing compressed data. Unlike # Zlib::Deflate, an instance of this class is not able to duplicate (clone, # dup) itself. class Inflate < ZStream ## # Decompresses +string+. Raises a Zlib::NeedDict exception if a preset # dictionary is needed for decompression. # # This method is almost equivalent to the following code: # # def inflate(string) # zstream = Zlib::Inflate.new # buf = zstream.inflate(string) # zstream.finish # zstream.close # buf # end def self.inflate(data) inflator = new unzipped = inflator.inflate data unzipped ensure inflator.end end ## # Creates a new inflate stream for decompression. See zlib.h for details # of the argument. If +window_bits+ is +nil+, the default value is used. def initialize(window_bits = Zlib::MAX_WBITS) super() @func_end = :inflateEnd @func_reset = :inflateReset @func_run = :inflate err = Zlib.inflateInit2 pointer, window_bits Zlib.handle_error err, message # HACK ready end ## # Inputs +string+ into the inflate stream just like Zlib::Inflate#inflate, # but returns the Zlib::Inflate object itself. The output from the stream # is preserved in output buffer. def <<(string) string = StringValue string unless string.nil? if finished? then unless string.nil? then @input ||= '' @input << string end else run string, Zlib::SYNC_FLUSH end end ## # Inputs +string+ into the inflate stream and returns the output from the # stream. Calling this method, both the input and the output buffer of # the stream are flushed. If string is +nil+, this method finishes the
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
true
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/sparcv9-solaris/sysconf.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/sparcv9-solaris/sysconf.rb
# This file is generated by rake. Do not edit. module Platform;end module Platform::Sysconf SC_2_CHAR_TERM = 66 SC_2_C_BIND = 45 SC_2_C_DEV = 46 SC_2_FORT_DEV = 48 SC_2_FORT_RUN = 49 SC_2_LOCALEDEF = 50 SC_2_PBS = 724 SC_2_PBS_ACCOUNTING = 725 SC_2_PBS_CHECKPOINT = 726 SC_2_PBS_LOCATE = 728 SC_2_PBS_MESSAGE = 729 SC_2_PBS_TRACK = 730 SC_2_SW_DEV = 51 SC_2_UPE = 52 SC_2_VERSION = 53 SC_ADVISORY_INFO = 731 SC_AIO_LISTIO_MAX = 18 SC_AIO_MAX = 19 SC_AIO_PRIO_DELTA_MAX = 20 SC_ARG_MAX = 1 SC_ASYNCHRONOUS_IO = 21 SC_ATEXIT_MAX = 76 SC_BARRIERS = 732 SC_BC_BASE_MAX = 54 SC_BC_DIM_MAX = 55 SC_BC_SCALE_MAX = 56 SC_BC_STRING_MAX = 57 SC_CHILD_MAX = 2 SC_CLK_TCK = 3 SC_CLOCK_SELECTION = 733 SC_COLL_WEIGHTS_MAX = 58 SC_CPUTIME = 734 SC_DELAYTIMER_MAX = 22 SC_EXPR_NEST_MAX = 59 # _SC_FILE_LOCKING not available SC_FSYNC = 23 SC_GETGR_R_SIZE_MAX = 569 SC_GETPW_R_SIZE_MAX = 570 SC_HOST_NAME_MAX = 735 SC_IOV_MAX = 77 SC_IPV6 = 762 SC_JOB_CONTROL = 6 SC_LINE_MAX = 60 SC_LOGIN_NAME_MAX = 571 SC_MAPPED_FILES = 24 SC_MEMLOCK = 25 SC_MEMLOCK_RANGE = 26 SC_MEMORY_PROTECTION = 27 SC_MESSAGE_PASSING = 28 SC_MONOTONIC_CLOCK = 736 SC_MQ_OPEN_MAX = 29 SC_MQ_PRIO_MAX = 30 SC_NGROUPS_MAX = 4 SC_NPROCESSORS_CONF = 14 SC_NPROCESSORS_ONLN = 15 SC_OPEN_MAX = 5 SC_PAGESIZE = 11 SC_PAGE_SIZE = 11 SC_PASS_MAX = 9 SC_PRIORITIZED_IO = 31 SC_PRIORITY_SCHEDULING = 32 SC_RAW_SOCKETS = 763 SC_READER_WRITER_LOCKS = 737 SC_REALTIME_SIGNALS = 33 SC_REGEXP = 738 SC_RE_DUP_MAX = 61 SC_RTSIG_MAX = 34 SC_SAVED_IDS = 7 SC_SEMAPHORES = 35 SC_SEM_NSEMS_MAX = 36 SC_SEM_VALUE_MAX = 37 SC_SHARED_MEMORY_OBJECTS = 38 SC_SHELL = 739 SC_SIGQUEUE_MAX = 39 SC_SPAWN = 740 SC_SPIN_LOCKS = 741 SC_SPORADIC_SERVER = 742 SC_SS_REPL_MAX = 743 SC_STREAM_MAX = 16 SC_SYMLOOP_MAX = 744 SC_SYNCHRONIZED_IO = 42 SC_THREADS = 576 SC_THREAD_ATTR_STACKADDR = 577 SC_THREAD_ATTR_STACKSIZE = 578 SC_THREAD_CPUTIME = 745 SC_THREAD_DESTRUCTOR_ITERATIONS = 568 SC_THREAD_KEYS_MAX = 572 SC_THREAD_PRIORITY_SCHEDULING = 579 SC_THREAD_PRIO_INHERIT = 580 SC_THREAD_PRIO_PROTECT = 581 SC_THREAD_PROCESS_SHARED = 582 SC_THREAD_SAFE_FUNCTIONS = 583 SC_THREAD_SPORADIC_SERVER = 746 SC_THREAD_STACK_MIN = 573 SC_THREAD_THREADS_MAX = 574 SC_TIMEOUTS = 747 SC_TIMERS = 43 SC_TIMER_MAX = 44 SC_TRACE = 748 SC_TRACE_EVENT_FILTER = 749 SC_TRACE_EVENT_NAME_MAX = 750 SC_TRACE_INHERIT = 751 SC_TRACE_LOG = 752 SC_TRACE_NAME_MAX = 753 SC_TRACE_SYS_MAX = 754 SC_TRACE_USER_EVENT_MAX = 755 SC_TTY_NAME_MAX = 575 SC_TYPED_MEMORY_OBJECTS = 756 SC_TZNAME_MAX = 17 SC_V6_ILP32_OFF32 = 757 SC_V6_ILP32_OFFBIG = 758 SC_V6_LP64_OFF64 = 759 SC_V6_LPBIG_OFFBIG = 760 SC_VERSION = 8 SC_XBS5_ILP32_OFF32 = 720 SC_XBS5_ILP32_OFFBIG = 721 SC_XBS5_LP64_OFF64 = 722 SC_XBS5_LPBIG_OFFBIG = 723 SC_XOPEN_CRYPT = 62 SC_XOPEN_ENH_I18N = 63 SC_XOPEN_LEGACY = 717 SC_XOPEN_REALTIME = 718 SC_XOPEN_REALTIME_THREADS = 719 SC_XOPEN_SHM = 64 SC_XOPEN_STREAMS = 761 SC_XOPEN_UNIX = 78 SC_XOPEN_VERSION = 12 SC_XOPEN_XCU_VERSION = 67 end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-solaris/errno.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-solaris/errno.rb
# This file is generated by rake. Do not edit. module Platform; end module Platform::Errno E2BIG = 7 EACCES = 13 EADDRINUSE = 125 EADDRNOTAVAIL = 126 EAFNOSUPPORT = 124 EAGAIN = 11 EALREADY = 149 EBADF = 9 EBUSY = 16 ECHILD = 10 ECONNABORTED = 130 ECONNREFUSED = 146 ECONNRESET = 131 EDEADLK = 45 EDESTADDRREQ = 96 EEXIST = 17 EFAULT = 14 EFBIG = 27 EHOSTDOWN = 147 EHOSTUNREACH = 148 EINPROGRESS = 150 EINTR = 4 EINVAL = 22 EIO = 5 EISCONN = 133 EISDIR = 21 ELOOP = 90 EMFILE = 24 EMLINK = 31 EMSGSIZE = 97 ENAMETOOLONG = 78 ENETDOWN = 127 ENETRESET = 129 ENETUNREACH = 128 ENFILE = 23 ENOBUFS = 132 ENODEV = 19 ENOENT = 2 ENOEXEC = 8 ENOMEM = 12 ENOPROTOOPT = 99 ENOSPC = 28 ENOTCONN = 134 ENOTDIR = 20 ENOTEMPTY = 93 ENOTSOCK = 95 ENOTTY = 25 ENXIO = 6 EOPNOTSUPP = 122 EPERM = 1 EPIPE = 32 EPROTONOSUPPORT = 120 EPROTOTYPE = 98 EROFS = 30 ESPIPE = 29 ESRCH = 3 ETIMEDOUT = 145 ETXTBSY = 26 EWOULDBLOCK = 11 EXDEV = 18 end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-solaris/socket.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-solaris/socket.rb
# This file is generated by rake. Do not edit. module Platform; end module Platform::Socket AF_APPLETALK = 16 # AF_ATM not available # AF_AX25 not available AF_CCITT = 10 AF_CHAOS = 5 # AF_CNT not available # AF_COIP not available AF_DATAKIT = 9 AF_DECnet = 12 AF_DLI = 13 # AF_E164 not available AF_ECMA = 8 AF_HYLINK = 15 AF_IMPLINK = 3 AF_INET = 2 AF_INET6 = 26 AF_IPX = 23 # AF_ISDN not available # AF_ISO not available AF_LAT = 14 AF_LINK = 25 AF_LOCAL = 1 AF_MAX = 30 # AF_NATM not available # AF_NDRV not available # AF_NETBIOS not available # AF_NETGRAPH not available AF_NS = 6 AF_OSI = 19 # AF_PPP not available AF_PUP = 4 AF_ROUTE = 24 # AF_SIP not available AF_SNA = 11 # AF_SYSTEM not available AF_UNIX = 1 AF_UNSPEC = 0 NI_DGRAM = 16 # NI_FQDN_FLAG_VALIDTTL not available NI_MAXHOST = 1025 NI_MAXSERV = 32 NI_NAMEREQD = 4 # NI_NODEADDR_FLAG_ALL not available # NI_NODEADDR_FLAG_ANYCAST not available # NI_NODEADDR_FLAG_COMPAT not available # NI_NODEADDR_FLAG_GLOBAL not available # NI_NODEADDR_FLAG_LINKLOCAL not available # NI_NODEADDR_FLAG_SITELOCAL not available # NI_NODEADDR_FLAG_TRUNCATE not available NI_NOFQDN = 1 NI_NUMERICHOST = 2 NI_NUMERICSERV = 8 # NI_QTYPE_DNSNAME not available # NI_QTYPE_FQDN not available # NI_QTYPE_IPV4ADDR not available # NI_QTYPE_NODEADDR not available # NI_QTYPE_NOOP not available # NI_QTYPE_SUPTYPES not available # NI_SUPTYPE_FLAG_COMPRESS not available NI_WITHSCOPEID = 32 PF_APPLETALK = 16 # PF_ATM not available PF_CCITT = 10 PF_CHAOS = 5 # PF_CNT not available # PF_COIP not available PF_DATAKIT = 9 PF_DECnet = 12 PF_DLI = 13 PF_ECMA = 8 PF_HYLINK = 15 PF_IMPLINK = 3 PF_INET = 2 PF_INET6 = 26 PF_IPX = 23 # PF_ISDN not available # PF_ISO not available PF_KEY = 27 PF_LAT = 14 PF_LINK = 25 PF_LOCAL = 1 PF_MAX = 30 # PF_NATM not available # PF_NDRV not available # PF_NETBIOS not available # PF_NETGRAPH not available PF_NS = 6 PF_OSI = 19 # PF_PIP not available # PF_PPP not available PF_PUP = 4 PF_ROUTE = 24 # PF_RTIP not available # PF_SIP not available PF_SNA = 11 # PF_SYSTEM not available PF_UNIX = 1 PF_UNSPEC = 0 # PF_XTP not available SOCK_DGRAM = 1 # SOCK_MAXADDRLEN not available SOCK_RAW = 4 SOCK_RDM = 5 SOCK_SEQPACKET = 6 SOCK_STREAM = 2 SO_ACCEPTCONN = 2 # SO_ACCEPTFILTER not available # SO_ATTACH_FILTER not available # SO_BINDTODEVICE not available SO_BROADCAST = 32 SO_DEBUG = 1 # SO_DETACH_FILTER not available SO_DONTROUTE = 16 # SO_DONTTRUNC not available SO_ERROR = 4103 SO_KEEPALIVE = 8 # SO_LABEL not available SO_LINGER = 128 # SO_NKE not available # SO_NOADDRERR not available # SO_NOSIGPIPE not available # SO_NO_CHECK not available # SO_NREAD not available # SO_NWRITE not available SO_OOBINLINE = 256 # SO_PASSCRED not available # SO_PEERCRED not available # SO_PEERLABEL not available # SO_PEERNAME not available # SO_PRIORITY not available SO_RCVBUF = 4098 SO_RCVLOWAT = 4100 SO_RCVTIMEO = 4102 SO_REUSEADDR = 4 # SO_REUSEPORT not available # SO_REUSESHAREUID not available # SO_SECURITY_AUTHENTICATION not available # SO_SECURITY_ENCRYPTION_NETWORK not available # SO_SECURITY_ENCRYPTION_TRANSPORT not available SO_SNDBUF = 4097 SO_SNDLOWAT = 4099 SO_SNDTIMEO = 4101 SO_TIMESTAMP = 4115 SO_TYPE = 4104 SO_USELOOPBACK = 64 # SO_WANTMORE not available # SO_WANTOOBFLAG not available # pseudo_AF_HDRCMPLT not available # pseudo_AF_KEY not available # pseudo_AF_PIP not available # pseudo_AF_RTIP not available # pseudo_AF_XTP not available end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-solaris/stat.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-solaris/stat.rb
# This file is generated by rake. Do not edit. module Platform module Stat class Stat < FFI::Struct self.size = 128 layout :st_dev, :dev_t, 0, :st_ino, :ino_t, 8, :st_nlink, :nlink_t, 20, :st_mode, :mode_t, 16, :st_uid, :uid_t, 24, :st_gid, :gid_t, 28, :st_size, :off_t, 40, :st_blocks, :blkcnt_t, 104, :st_atime, :time_t, 48, :st_mtime, :time_t, 64, :st_ctime, :time_t, 80 end module Constants S_IEXEC = 0x40 S_IREAD = 0x100 S_IRGRP = 0x20 S_IROTH = 0x4 S_IRUSR = 0x100 S_IRWXG = 0x38 S_IRWXO = 0x7 S_IRWXU = 0x1c0 S_ISGID = 0x400 S_ISUID = 0x800 S_IWGRP = 0x10 S_IWOTH = 0x2 S_IWRITE = 0x80 S_IWUSR = 0x80 S_IXGRP = 0x8 S_IXOTH = 0x1 S_IXUSR = 0x40 end include Constants end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-solaris/etc.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-solaris/etc.rb
# This file is generated by rake. Do not edit. module Platform; end module Platform::Etc class Passwd < FFI::Struct self.size = 64 layout :pw_name, :string, 0, :pw_passwd, :string, 8, :pw_uid, :uint, 16, :pw_gid, :uint, 20, :pw_dir, :string, 48, :pw_shell, :string, 56 end class Group < FFI::Struct self.size = 32 layout :gr_name, :string, 0, :gr_gid, :uint, 16 end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-solaris/syslog.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-solaris/syslog.rb
# This file is generated by rake. Do not edit. module Syslog module Constants LOG_ALERT = 1 LOG_AUTH = 32 # LOG_AUTHPRIV not available LOG_CONS = 2 # LOG_CONSOLE not available LOG_CRIT = 2 LOG_CRON = 120 LOG_DAEMON = 24 LOG_DEBUG = 7 LOG_EMERG = 0 LOG_ERR = 3 # LOG_FTP not available LOG_INFO = 6 LOG_KERN = 0 LOG_LOCAL0 = 128 LOG_LOCAL1 = 136 LOG_LOCAL2 = 144 LOG_LOCAL3 = 152 LOG_LOCAL4 = 160 LOG_LOCAL5 = 168 LOG_LOCAL6 = 176 LOG_LOCAL7 = 184 LOG_LPR = 48 LOG_MAIL = 16 LOG_NEWS = 56 # LOG_NODELAY not available LOG_NOTICE = 5 LOG_NOWAIT = 16 # LOG_NTP not available LOG_ODELAY = 4 # LOG_PERROR not available LOG_PID = 1 # LOG_SECURITY not available LOG_SYSLOG = 40 LOG_USER = 8 LOG_UUCP = 64 LOG_WARNING = 4 end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-solaris/fcntl.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-solaris/fcntl.rb
# This file is generated by rake. Do not edit. module Fcntl FD_CLOEXEC = 1 F_DUPFD = 0 F_GETFD = 1 F_GETFL = 3 F_GETLK = 14 F_RDLCK = 1 F_SETFD = 2 F_SETFL = 4 F_SETLK = 6 F_SETLKW = 7 F_UNLCK = 3 F_WRLCK = 2 O_ACCMODE = 3 O_APPEND = 8 O_CREAT = 256 O_EXCL = 1024 O_NDELAY = 4 O_NOCTTY = 2048 O_NONBLOCK = 128 O_RDONLY = 0 O_RDWR = 2 O_TRUNC = 512 O_WRONLY = 1 end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-solaris/zlib.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-solaris/zlib.rb
# This file is generated by rake. Do not edit. ## # The Zlib module contains several classes for compressing and decompressing # streams, and for working with "gzip" files. # # == Classes # # Following are the classes that are most likely to be of interest to the # user: # - Zlib::Inflate # - Zlib::Deflate # - Zlib::GzipReader # - Zlib::GzipWriter # # There are two important base classes for the classes above: Zlib::ZStream # and Zlib::GzipFile. Everything else is an error class. # # == Constants # # Here's a list. # # Zlib::VERSION # The Ruby/zlib version string. # # Zlib::ZLIB_VERSION # The string which represents the version of zlib.h. # # Zlib::BINARY # Zlib::ASCII # Zlib::UNKNOWN # The integers representing data types which Zlib::ZStream#data_type # method returns. # # Zlib::NO_COMPRESSION # Zlib::BEST_SPEED # Zlib::BEST_COMPRESSION # Zlib::DEFAULT_COMPRESSION # The integers representing compression levels which are an argument # for Zlib::Deflate.new, Zlib::Deflate#deflate, and so on. # # Zlib::FILTERED # Zlib::HUFFMAN_ONLY # Zlib::DEFAULT_STRATEGY # The integers representing compression methods which are an argument # for Zlib::Deflate.new and Zlib::Deflate#params. # # Zlib::DEF_MEM_LEVEL # Zlib::MAX_MEM_LEVEL # The integers representing memory levels which are an argument for # Zlib::Deflate.new, Zlib::Deflate#params, and so on. # # Zlib::MAX_WBITS # The default value of windowBits which is an argument for # Zlib::Deflate.new and Zlib::Inflate.new. # # Zlib::NO_FLUSH # Zlib::SYNC_FLUSH # Zlib::FULL_FLUSH # Zlib::FINISH # The integers to control the output of the deflate stream, which are # an argument for Zlib::Deflate#deflate and so on. #-- # These constants are missing! # # Zlib::OS_CODE # Zlib::OS_MSDOS # Zlib::OS_AMIGA # Zlib::OS_VMS # Zlib::OS_UNIX # Zlib::OS_VMCMS # Zlib::OS_ATARI # Zlib::OS_OS2 # Zlib::OS_MACOS # Zlib::OS_ZSYSTEM # Zlib::OS_CPM # Zlib::OS_TOPS20 # Zlib::OS_WIN32 # Zlib::OS_QDOS # Zlib::OS_RISCOS # Zlib::OS_UNKNOWN # The return values of Zlib::GzipFile#os_code method. module Zlib ZLIB_VERSION = "1.2.3" BEST_COMPRESSION = 9 BEST_SPEED = 1 BLOCK = 5 BUF_ERROR = -5 DATA_ERROR = -3 DEFAULT_COMPRESSION = -1 DEFAULT_STRATEGY = 0 DEFLATED = 8 ERRNO = -1 FILTERED = 1 FINISH = 4 FIXED = 4 FULL_FLUSH = 3 HUFFMAN_ONLY = 2 MEM_ERROR = -4 NEED_DICT = 2 NO_COMPRESSION = 0 NO_FLUSH = 0 OK = 0 PARTIAL_FLUSH = 1 RLE = 3 STREAM_END = 1 STREAM_ERROR = -2 SYNC_FLUSH = 2 VERSION_ERROR = -6 # DEF_MEM_LEVEL not available MAX_MEM_LEVEL = 9 MAX_WBITS = 15 OS_MSDOS = 0x00 OS_AMIGA = 0x01 OS_VMS = 0x02 OS_UNIX = 0x03 OS_ATARI = 0x05 OS_OS2 = 0x06 OS_MACOS = 0x07 OS_TOPS20 = 0x0a OS_WIN32 = 0x0b OS_VMCMS = 0x04 OS_ZSYSTEM = 0x08 OS_CPM = 0x09 OS_QDOS = 0x0c OS_RISCOS = 0x0d OS_UNKNOWN = 0xff # OS_CODE not available unless defined? OS_CODE then OS_CODE = OS_UNIX end # from zutil.h unless defined? DEF_MEM_LEVEL then DEF_MEM_LEVEL = MAX_MEM_LEVEL >= 8 ? 8 : MAX_MEM_LEVEL end class Error < StandardError; end class StreamEnd < Error; end class NeedDict < Error; end class StreamError < Error; end class DataError < Error; end class BufError < Error; end class VersionError < Error; end class MemError < Error; end ## # Zlib::ZStream is the abstract class for the stream which handles the # compressed data. The operations are defined in the subclasses: # Zlib::Deflate for compression, and Zlib::Inflate for decompression. # # An instance of Zlib::ZStream has one stream (struct zstream in the source) # and two variable-length buffers which associated to the input (next_in) of # the stream and the output (next_out) of the stream. In this document, # "input buffer" means the buffer for input, and "output buffer" means the # buffer for output. # # Data input into an instance of Zlib::ZStream are temporally stored into # the end of input buffer, and then data in input buffer are processed from # the beginning of the buffer until no more output from the stream is # produced (i.e. until avail_out > 0 after processing). During processing, # output buffer is allocated and expanded automatically to hold all output # data. # # Some particular instance methods consume the data in output buffer and # return them as a String. # # Here is an ascii art for describing above: # # +================ an instance of Zlib::ZStream ================+ # || || # || +--------+ +-------+ +--------+ || # || +--| output |<---------|zstream|<---------| input |<--+ || # || | | buffer | next_out+-------+next_in | buffer | | || # || | +--------+ +--------+ | || # || | | || # +===|======================================================|===+ # | | # v | # "output data" "input data" # # If an error occurs during processing input buffer, an exception which is a # subclass of Zlib::Error is raised. At that time, both input and output # buffer keep their conditions at the time when the error occurs. # # == Method Catalogue # # Many of the methods in this class are fairly low-level and unlikely to be # of interest to users. In fact, users are unlikely to use this class # directly; rather they will be interested in Zlib::Inflate and # Zlib::Deflate. # # The higher level methods are listed below. # # - #total_in # - #total_out # - #data_type # - #adler # - #reset # - #finish # - #finished? # - #close # - #closed? class ZStream < FFI::Struct self.size = 112 layout :next_in, :pointer, 0, :avail_in, :uint, 8, :total_in, :ulong, 16, :next_out, :pointer, 24, :avail_out, :uint, 32, :total_out, :ulong, 40, :msg, :string, 48, :state, :pointer, 56, :zalloc, :pointer, 64, :zfree, :pointer, 72, :opaque, :pointer, 80, :data_type, :int, 88, :adler, :ulong, 96, :reserved, :ulong, 104 #-- # HACK from MRI's zlib.c #++ READY = 0x1 IN_STREAM = 0x2 FINISHED = 0x4 CLOSING = 0x8 UNUSED = 0x10 attr_accessor :flags attr_reader :input attr_reader :output def self.inherited(subclass) subclass.instance_variable_set :@layout, @layout subclass.instance_variable_set :@size, @size end def initialize super self[:avail_in] = 0 self[:avail_out] = 0 self[:next_in] = nil self[:opaque] = nil self[:zalloc] = nil self[:zfree] = nil reset_input @output = nil @flags = 0 @func = nil end def closing? @flags & CLOSING == CLOSING end def detatch_output if @output.nil? then data = '' else data = @output @output = nil self[:avail_out] = 0 self[:next_out] = nil end data end ## # Closes the stream. All operations on the closed stream will raise an # exception. def end unless ready? then warn "attempt to close uninitialized stream; ignored." return nil end if in_stream? then warn "attempt to close unfinished zstream; reset forced" reset end reset_input err = Zlib.send @func_end, pointer Zlib.handle_error err, message @flags = 0 # HACK this may be wrong @output = nil @next_out.free unless @next_out.nil? @next_out = nil nil end alias :close :end def expand_output if @output.nil? then @output = '' @next_out = MemoryPointer.new CHUNK if @next_out.nil? @next_out.write_string "\000" * CHUNK self[:next_out] = @next_out else have = CHUNK - self[:avail_out] @output << @next_out.read_string(have) self[:next_out] = @next_out # Zlib advances self[:next_out] end self[:avail_out] = CHUNK end ## # Finishes the stream and flushes output buffer. See Zlib::Deflate#finish # and Zlib::Inflate#finish for details of this behavior. def finish run '', Zlib::FINISH detatch_output end ## # Returns true if the stream is finished. def finished? @flags & FINISHED == FINISHED end ## # Flushes output buffer and returns all data in that buffer. def flush_next_out detatch_output end def in_stream? @flags & IN_STREAM == IN_STREAM end def input_empty? @input.nil? or @input.empty? end ## # The msg field of the struct def message self[:msg] end def ready @flags |= READY end def ready? @flags & READY == READY end ## # Resets and initializes the stream. All data in both input and output # buffer are discarded. def reset err = Zlib.send @func_reset, pointer Zlib.handle_error err, message @flags = READY reset_input end def reset_input @input = nil end def run(data, flush) if @input.nil? and data.empty? then data_in = MemoryPointer.new 1 data_in.write_string "\000", 1 self[:next_in] = data_in self[:avail_in] = 0 else @input ||= '' @input << data data_in = MemoryPointer.new @input.length data_in.write_string @input, @input.length self[:next_in] = data_in self[:avail_in] = @input.length end expand_output if self[:avail_out] == 0 loop do err = Zlib.send @func_run, pointer, flush available = self[:avail_out] expand_output # HACK does this work when err is set? if err == Zlib::STREAM_END then @flags &= ~IN_STREAM @flags |= FINISHED break end unless err == Zlib::OK then if flush != Zlib::FINISH and err == Zlib::BUF_ERROR and self[:avail_out] > 0 then @flags |= IN_STREAM break end if self[:avail_in] > 0 then @input = self[:next_in].read_string(self[:avail_in]) + @input end Zlib.handle_error err, message end if available > 0 then @flags |= IN_STREAM break end end reset_input if self[:avail_in] > 0 then @input = self[:next_in].read_string self[:avail_in] end ensure data_in.free self[:next_in] = nil end ## # Returns the number of bytes consumed def total_in self[:total_in] end ## # Returns the number bytes processed def total_out self[:total_out] end end set_ffi_lib 'libz' # deflateInit2 is a macro pointing to deflateInit2_ attach_function :deflateInit2_, [ :pointer, # z_streamp strm :int, # int level :int, # int method :int, # int windowBits :int, # int memLevel :int, # int strategy :string, # ZLIB_VERSION :int # (int)sizeof(z_stream) ], :int def self.deflateInit2(stream, level, method, window_bits, mem_level, strategy) deflateInit2_ stream, level, method, window_bits, mem_level, strategy, ZLIB_VERSION, ZStream.size end attach_function :deflate, [:pointer, :int], :int attach_function :deflateEnd, [:pointer], :int attach_function :deflateParams, [:pointer, :int, :int], :int attach_function :deflateReset, [:pointer], :int attach_function :deflateSetDictionary, [:pointer, :string, :uint], :int # inflateInit2 is a macro pointing to inflateInit2_ attach_function :inflateInit2_, [:pointer, :int, :string, :int], :int def self.inflateInit2(stream, window_bits) inflateInit2_ stream, window_bits, ZLIB_VERSION, ZStream.size end attach_function :inflate, [:pointer, :int], :int attach_function :inflateEnd, [:pointer], :int attach_function :inflateReset, [:pointer], :int attach_function :inflateSetDictionary, [:pointer, :string, :uint], :int attach_function :adler32_c, :adler32, [:ulong, :string, :uint], :ulong attach_function :crc32_c, :crc32, [:ulong, :string, :uint], :ulong attach_function :get_crc_table_c, :get_crc_table, [], :pointer attach_function :zError, [:int], :string # Chunk size for inflation and deflation CHUNK = 1024 #-- # HACK from zlib.c #++ GZ_EXTRAFLAG_FAST = 0x4 GZ_EXTRAFLAG_SLOW = 0x2 ## # Zlib::Deflate is the class for compressing data. See Zlib::ZStream for # more information. class Deflate < ZStream ## # Compresses the given +string+. Valid values of level are # <tt>Zlib::NO_COMPRESSION</tt>, <tt>Zlib::BEST_SPEED</tt>, # <tt>Zlib::BEST_COMPRESSION</tt>, <tt>Zlib::DEFAULT_COMPRESSION</tt>, and # an integer from 0 to 9. # # This method is almost equivalent to the following code: # # def deflate(string, level) # z = Zlib::Deflate.new(level) # dst = z.deflate(string, Zlib::FINISH) # z.close # dst # end def self.deflate(data, level = Zlib::DEFAULT_COMPRESSION) deflator = new level zipped = deflator.deflate data, Zlib::FINISH zipped ensure deflator.end end ## # Creates a new deflate stream for compression. See zlib.h for details of # each argument. If an argument is nil, the default value of that argument # is used. def initialize(level = Zlib::DEFAULT_COMPRESSION, window_bits = Zlib::MAX_WBITS, mem_level = Zlib::DEF_MEM_LEVEL, strategy = Zlib::DEFAULT_STRATEGY) level ||= Zlib::DEFAULT_COMPRESSION window_bits ||= Zlib::MAX_WBITS mem_level ||= Zlib::DEF_MEM_LEVEL strategy ||= Zlib::DEFAULT_STRATEGY super() @func_end = :deflateEnd @func_reset = :deflateReset @func_run = :deflate err = Zlib.deflateInit2(pointer, level, Zlib::DEFLATED, window_bits, mem_level, strategy) Zlib.handle_error err, message ready end ## # Same as IO. def <<(data) do_deflate data, Zlib::NO_FLUSH self end ## # Inputs +string+ into the deflate stream and returns the output from the # stream. On calling this method, both the input and the output buffers # of the stream are flushed. If +string+ is nil, this method finishes the # stream, just like Zlib::ZStream#finish. # # The value of +flush+ should be either <tt>Zlib::NO_FLUSH</tt>, # <tt>Zlib::SYNC_FLUSH</tt>, <tt>Zlib::FULL_FLUSH</tt>, or # <tt>Zlib::FINISH</tt>. See zlib.h for details. def deflate(data, flush = Zlib::NO_FLUSH) do_deflate data, flush detatch_output end ## # Performs the deflate operation and leaves the compressed data in the # output buffer def do_deflate(data, flush) if data.nil? then run '', Zlib::FINISH else data = StringValue data if flush != Zlib::NO_FLUSH or not data.empty? then # prevent BUF_ERROR run data, flush end end end ## # Finishes compressing the deflate input stream and returns the output # buffer. def finish run '', Zlib::FINISH detatch_output end ## # This method is equivalent to <tt>deflate('', flush)</tt>. If flush is # omitted, <tt>Zlib::SYNC_FLUSH</tt> is used as flush. This method is # just provided to improve the readability of your Ruby program. def flush(flush = Zlib::SYNC_FLUSH) run '', flush unless flush == Zlib::NO_FLUSH detatch_output end ## # Changes the parameters of the deflate stream. See zlib.h for details. # The output from the stream by changing the params is preserved in output # buffer. def params(level, strategy) err = Zlib.deflateParams pointer, level, strategy raise Zlib::BufError, 'buffer expansion not implemented' if err == Zlib::BUF_ERROR Zlib.handle_error err, message nil end ## # Sets the preset dictionary and returns +dictionary+. This method is # available just only after Zlib::Deflate.new or Zlib::ZStream#reset # method was called. See zlib.h for details. def set_dictionary(dictionary) dict = StringValue dictionary err = Zlib.deflateSetDictionary pointer, dict, dict.length Zlib.handle_error err, message dictionary end end ## # Zlib::GzipFile is an abstract class for handling a gzip formatted # compressed file. The operations are defined in the subclasses, # Zlib::GzipReader for reading, and Zlib::GzipWriter for writing. # # GzipReader should be used by associating an IO, or IO-like, object. class GzipFile SYNC = Zlib::ZStream::UNUSED HEADER_FINISHED = Zlib::ZStream::UNUSED << 1 FOOTER_FINISHED = Zlib::ZStream::UNUSED << 2 FLAG_MULTIPART = 0x2 FLAG_EXTRA = 0x4 FLAG_ORIG_NAME = 0x8 FLAG_COMMENT = 0x10 FLAG_ENCRYPT = 0x20 FLAG_UNKNOWN_MASK = 0xc0 EXTRAFLAG_FAST = 0x4 EXTRAFLAG_SLOW = 0x2 MAGIC1 = 0x1f MAGIC2 = 0x8b METHOD_DEFLATE = 8 ## # Base class of errors that occur when processing GZIP files. class Error < Zlib::Error; end ## # Raised when gzip file footer is not found. class NoFooter < Error; end ## # Raised when the CRC checksum recorded in gzip file footer is not # equivalent to the CRC checksum of the actual uncompressed data. class CRCError < Error; end ## # Raised when the data length recorded in the gzip file footer is not # equivalent to the length of the actual uncompressed data. class LengthError < Error; end ## # Accessor for the underlying ZStream attr_reader :zstream # :nodoc: ## # See Zlib::GzipReader#wrap and Zlib::GzipWriter#wrap. def self.wrap(*args) obj = new(*args) if block_given? then begin yield obj ensure obj.close if obj.zstream.ready? end end end def initialize @comment = nil @crc = 0 @level = nil @mtime = Time.at 0 @orig_name = nil @os_code = Zlib::OS_CODE end ## # Closes the GzipFile object. This method calls close method of the # associated IO object. Returns the associated IO object. def close io = finish io.close if io.respond_to? :close io end ## # Same as IO def closed? @io.nil? end ## # Returns comments recorded in the gzip file header, or nil if the # comment is not present. def comment raise Error, 'closed gzip stream' if @io.nil? @comment.dup end def end return if @zstream.closing? @zstream.flags |= Zlib::ZStream::CLOSING begin end_run ensure @zstream.end end end ## # Closes the GzipFile object. Unlike Zlib::GzipFile#close, this method # never calls the close method of the associated IO object. Returns the # associated IO object. def finish self.end io = @io @io = nil @orig_name = nil @comment = nil io end def finished? @zstream.finished? and @zstream.output.empty? # HACK I think end def footer_finished? @zstream.flags & Zlib::GzipFile::FOOTER_FINISHED == Zlib::GzipFile::FOOTER_FINISHED end def header_finished? @zstream.flags & Zlib::GzipFile::HEADER_FINISHED == Zlib::GzipFile::HEADER_FINISHED end ## # Returns last modification time recorded in the gzip file header. def mtime Time.at @mtime end ## # Returns original filename recorded in the gzip file header, or +nil+ if # original filename is not present. def orig_name raise Error, 'closed gzip stream' if @io.nil? @orig_name.dup end end ## # Zlib::GzipReader is the class for reading a gzipped file. GzipReader # should be used an IO, or -IO-lie, object. # # Zlib::GzipReader.open('hoge.gz') {|gz| # print gz.read # } # # File.open('hoge.gz') do |f| # gz = Zlib::GzipReader.new(f) # print gz.read # gz.close # end # # == Method Catalogue # # The following methods in Zlib::GzipReader are just like their counterparts # in IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an # error was found in the gzip file. # # - #each # - #each_line # - #each_byte # - #gets # - #getc # - #lineno # - #lineno= # - #read # - #readchar # - #readline # - #readlines # - #ungetc # # Be careful of the footer of the gzip file. A gzip file has the checksum of # pre-compressed data in its footer. GzipReader checks all uncompressed data # against that checksum at the following cases, and if it fails, raises # <tt>Zlib::GzipFile::NoFooter</tt>, <tt>Zlib::GzipFile::CRCError</tt>, or # <tt>Zlib::GzipFile::LengthError</tt> exception. # # - When an reading request is received beyond the end of file (the end of # compressed data). That is, when Zlib::GzipReader#read, # Zlib::GzipReader#gets, or some other methods for reading returns nil. # - When Zlib::GzipFile#close method is called after the object reaches the # end of file. # - When Zlib::GzipReader#unused method is called after the object reaches # the end of file. # # The rest of the methods are adequately described in their own # documentation. class GzipReader < GzipFile # HACK use a buffer class ## # Creates a GzipReader object associated with +io+. The GzipReader object # reads gzipped data from +io+, and parses/decompresses them. At least, # +io+ must have a +read+ method that behaves same as the +read+ method in # IO class. # # If the gzip file header is incorrect, raises an Zlib::GzipFile::Error # exception. def initialize(io) @io = io @zstream = Zlib::Inflate.new -Zlib::MAX_WBITS @buffer = '' super() read_header end def check_footer @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED footer = @zstream.input.slice! 0, 8 rest = @io.read 8 - footer.length footer << rest if rest raise NoFooter, 'footer is not found' unless footer.length == 8 crc, length = footer.unpack 'VV' @zstream[:total_in] += 8 # to rewind correctly raise CRCError, 'invalid compressed data -- crc error' unless @crc == crc raise LengthError, 'invalid compressed data -- length error' unless length == @zstream.total_out end def end_run check_footer if @zstream.finished? and not footer_finished? end def eof? @zstream.finished? and @zstream.input_empty? end def pos @zstream[:total_out] - @buffer.length end ## # See Zlib::GzipReader documentation for a description. def read(length = nil) data = @buffer while chunk = @io.read(CHUNK) do inflated = @zstream.inflate(chunk) @crc = Zlib.crc32 inflated, @crc data << inflated break if length and data.length > length end if length then @buffer = data.slice! length..-1 else @buffer = '' end check_footer if @zstream.finished? and not footer_finished? data rescue Zlib::Error => e raise GzipFile::Error, e.message end def read_header header = @io.read 10 raise Error, 'not in gzip format' unless header.length == 10 magic1, magic2, method, flags, @mtime, extra_flags, @os_code = header.unpack 'CCCCVCC' unless magic1 == Zlib::GzipFile::MAGIC1 and magic2 == Zlib::GzipFile::MAGIC2 then raise Error, 'not in gzip format' end unless method == Zlib::GzipFile::METHOD_DEFLATE then raise Error, "unsupported compression method #{method}" end if flags & Zlib::GzipFile::FLAG_MULTIPART == Zlib::GzipFile::FLAG_MULTIPART then raise Error, 'multi-part gzip file is not supported' end if flags & Zlib::GzipFile::FLAG_ENCRYPT == Zlib::GzipFile::FLAG_ENCRYPT then raise Error, 'encrypted gzip file is not supported' end if flags & Zlib::GzipFile::FLAG_UNKNOWN_MASK == Zlib::GzipFile::FLAG_UNKNOWN_MASK then raise Error, "unknown flags 0x#{flags.to_s 16}" end if extra_flags & Zlib::GzipFile::EXTRAFLAG_FAST == Zlib::GzipFile::EXTRAFLAG_FAST then @level = Zlib::BEST_SPEED elsif extra_flags & Zlib::GzipFile::EXTRAFLAG_SLOW == Zlib::GzipFile::EXTRAFLAG_SLOW then @level = Zlib::BEST_COMPRESSION else @level = Zlib::DEFAULT_COMPRESSION end if flags & Zlib::GzipFile::FLAG_EXTRA == Zlib::GzipFile::FLAG_EXTRA then length = @io.read 2 raise Zlib::GzipFile::Error, 'unexpected end of file' if length.nil? or length.length != 2 length, = length.unpack 'v' extra = @io.read length + 2 raise Zlib::GzipFile::Error, 'unexpected end of file' if extra.nil? or extra.length != length + 2 end if flags & Zlib::GzipFile::FLAG_ORIG_NAME == Zlib::GzipFile::FLAG_ORIG_NAME then @orig_name = '' c = @io.getc until c == 0 do @orig_name << c.chr c = @io.getc end end if flags & Zlib::GzipFile::FLAG_COMMENT == Zlib::GzipFile::FLAG_COMMENT then @comment = '' c = @io.getc until c == 0 do @comment << c.chr c = @io.getc end end end end ## # Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should # be used with an instance of IO, or IO-like, object. # # For example: # # Zlib::GzipWriter.open('hoge.gz') do |gz| # gz.write 'jugemu jugemu gokou no surikire...' # end # # File.open('hoge.gz', 'w') do |f| # gz = Zlib::GzipWriter.new(f) # gz.write 'jugemu jugemu gokou no surikire...' # gz.close # end # # NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close # GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter # will be not able to write the gzip footer and will generate a broken gzip # file. class GzipWriter < GzipFile # HACK use a buffer class ## # Set the comment attr_writer :comment ## # Set the original name attr_writer :orig_name ## # Creates a GzipWriter object associated with +io+. +level+ and +strategy+ # should be the same as the arguments of Zlib::Deflate.new. The # GzipWriter object writes gzipped data to +io+. At least, +io+ must # respond to the +write+ method that behaves same as write method in IO # class. def initialize(io, level = Zlib::DEFAULT_COMPRESSION, strategy = Zlib::DEFAULT_STRATEGY) @io = io @zstream = Zlib::Deflate.new level, -Zlib::MAX_WBITS, Zlib::DEF_MEM_LEVEL, strategy @buffer = '' super() end def end_run make_header unless header_finished? @zstream.run '', Zlib::FINISH write_raw make_footer nil end ## # Flushes all the internal buffers of the GzipWriter object. The meaning # of +flush+ is same as in Zlib::Deflate#deflate. # <tt>Zlib::SYNC_FLUSH</tt> is used if +flush+ is omitted. It is no use # giving flush <tt>Zlib::NO_FLUSH</tt>. def flush true end ## # Writes out a gzip header def make_header flags = 0 extra_flags = 0 flags |= Zlib::GzipFile::FLAG_ORIG_NAME if @orig_name flags |= Zlib::GzipFile::FLAG_COMMENT if @comment extra_flags |= Zlib::GzipFile::EXTRAFLAG_FAST if @level == Zlib::BEST_SPEED extra_flags |= Zlib::GzipFile::EXTRAFLAG_SLOW if @level == Zlib::BEST_COMPRESSION header = [ Zlib::GzipFile::MAGIC1, # byte 0 Zlib::GzipFile::MAGIC2, # byte 1 Zlib::GzipFile::METHOD_DEFLATE, # byte 2 flags, # byte 3 @mtime.to_i, # bytes 4-7 extra_flags, # byte 8 @os_code # byte 9 ].pack 'CCCCVCC' @io.write header @io.write "#{@orig_name}\0" if @orig_name @io.write "#{@comment}\0" if @comment @zstream.flags |= Zlib::GzipFile::HEADER_FINISHED end ## # Writes out a gzip footer def make_footer footer = [ @crc, # bytes 0-3 @zstream.total_in, # bytes 4-7 ].pack 'VV' @io.write footer @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED end ## # Sets the modification time of this file def mtime=(time) if header_finished? then raise Zlib::GzipFile::Error, 'header is already written' end @mtime = Integer time end def sync? @zstream.flags & Zlib::GzipFile::SYNC == Zlib::GzipFile::SYNC end ## # Same as IO. def write(data) make_header unless header_finished? data = String data if data.length > 0 or sync? then @crc = Zlib.crc32_c @crc, data, data.length flush = sync? ? Zlib::SYNC_FLUSH : Zlib::NO_FLUSH @zstream.run data, flush end write_raw end ## # Same as IO. alias << write def write_raw data = @zstream.detatch_output unless data.empty? then @io.write data @io.flush if sync? and io.respond_to :flush end end end ## # Zlib:Inflate is the class for decompressing compressed data. Unlike # Zlib::Deflate, an instance of this class is not able to duplicate (clone, # dup) itself. class Inflate < ZStream ## # Decompresses +string+. Raises a Zlib::NeedDict exception if a preset # dictionary is needed for decompression. # # This method is almost equivalent to the following code: # # def inflate(string) # zstream = Zlib::Inflate.new # buf = zstream.inflate(string) # zstream.finish # zstream.close # buf # end def self.inflate(data) inflator = new unzipped = inflator.inflate data unzipped ensure inflator.end end ## # Creates a new inflate stream for decompression. See zlib.h for details # of the argument. If +window_bits+ is +nil+, the default value is used. def initialize(window_bits = Zlib::MAX_WBITS) super() @func_end = :inflateEnd @func_reset = :inflateReset @func_run = :inflate err = Zlib.inflateInit2 pointer, window_bits Zlib.handle_error err, message # HACK ready end ## # Inputs +string+ into the inflate stream just like Zlib::Inflate#inflate, # but returns the Zlib::Inflate object itself. The output from the stream # is preserved in output buffer. def <<(string) string = StringValue string unless string.nil? if finished? then unless string.nil? then @input ||= '' @input << string end else run string, Zlib::SYNC_FLUSH end end ## # Inputs +string+ into the inflate stream and returns the output from the # stream. Calling this method, both the input and the output buffer of # the stream are flushed. If string is +nil+, this method finishes the
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
true
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-solaris/sysconf.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-solaris/sysconf.rb
# This file is generated by rake. Do not edit. module Platform;end module Platform::Sysconf SC_2_CHAR_TERM = 66 SC_2_C_BIND = 45 SC_2_C_DEV = 46 SC_2_FORT_DEV = 48 SC_2_FORT_RUN = 49 SC_2_LOCALEDEF = 50 SC_2_PBS = 724 SC_2_PBS_ACCOUNTING = 725 SC_2_PBS_CHECKPOINT = 726 SC_2_PBS_LOCATE = 728 SC_2_PBS_MESSAGE = 729 SC_2_PBS_TRACK = 730 SC_2_SW_DEV = 51 SC_2_UPE = 52 SC_2_VERSION = 53 SC_ADVISORY_INFO = 731 SC_AIO_LISTIO_MAX = 18 SC_AIO_MAX = 19 SC_AIO_PRIO_DELTA_MAX = 20 SC_ARG_MAX = 1 SC_ASYNCHRONOUS_IO = 21 SC_ATEXIT_MAX = 76 SC_BARRIERS = 732 SC_BC_BASE_MAX = 54 SC_BC_DIM_MAX = 55 SC_BC_SCALE_MAX = 56 SC_BC_STRING_MAX = 57 SC_CHILD_MAX = 2 SC_CLK_TCK = 3 SC_CLOCK_SELECTION = 733 SC_COLL_WEIGHTS_MAX = 58 SC_CPUTIME = 734 SC_DELAYTIMER_MAX = 22 SC_EXPR_NEST_MAX = 59 # _SC_FILE_LOCKING not available SC_FSYNC = 23 SC_GETGR_R_SIZE_MAX = 569 SC_GETPW_R_SIZE_MAX = 570 SC_HOST_NAME_MAX = 735 SC_IOV_MAX = 77 SC_IPV6 = 762 SC_JOB_CONTROL = 6 SC_LINE_MAX = 60 SC_LOGIN_NAME_MAX = 571 SC_MAPPED_FILES = 24 SC_MEMLOCK = 25 SC_MEMLOCK_RANGE = 26 SC_MEMORY_PROTECTION = 27 SC_MESSAGE_PASSING = 28 SC_MONOTONIC_CLOCK = 736 SC_MQ_OPEN_MAX = 29 SC_MQ_PRIO_MAX = 30 SC_NGROUPS_MAX = 4 SC_NPROCESSORS_CONF = 14 SC_NPROCESSORS_ONLN = 15 SC_OPEN_MAX = 5 SC_PAGESIZE = 11 SC_PAGE_SIZE = 11 SC_PASS_MAX = 9 SC_PRIORITIZED_IO = 31 SC_PRIORITY_SCHEDULING = 32 SC_RAW_SOCKETS = 763 SC_READER_WRITER_LOCKS = 737 SC_REALTIME_SIGNALS = 33 SC_REGEXP = 738 SC_RE_DUP_MAX = 61 SC_RTSIG_MAX = 34 SC_SAVED_IDS = 7 SC_SEMAPHORES = 35 SC_SEM_NSEMS_MAX = 36 SC_SEM_VALUE_MAX = 37 SC_SHARED_MEMORY_OBJECTS = 38 SC_SHELL = 739 SC_SIGQUEUE_MAX = 39 SC_SPAWN = 740 SC_SPIN_LOCKS = 741 SC_SPORADIC_SERVER = 742 SC_SS_REPL_MAX = 743 SC_STREAM_MAX = 16 SC_SYMLOOP_MAX = 744 SC_SYNCHRONIZED_IO = 42 SC_THREADS = 576 SC_THREAD_ATTR_STACKADDR = 577 SC_THREAD_ATTR_STACKSIZE = 578 SC_THREAD_CPUTIME = 745 SC_THREAD_DESTRUCTOR_ITERATIONS = 568 SC_THREAD_KEYS_MAX = 572 SC_THREAD_PRIORITY_SCHEDULING = 579 SC_THREAD_PRIO_INHERIT = 580 SC_THREAD_PRIO_PROTECT = 581 SC_THREAD_PROCESS_SHARED = 582 SC_THREAD_SAFE_FUNCTIONS = 583 SC_THREAD_SPORADIC_SERVER = 746 SC_THREAD_STACK_MIN = 573 SC_THREAD_THREADS_MAX = 574 SC_TIMEOUTS = 747 SC_TIMERS = 43 SC_TIMER_MAX = 44 SC_TRACE = 748 SC_TRACE_EVENT_FILTER = 749 SC_TRACE_EVENT_NAME_MAX = 750 SC_TRACE_INHERIT = 751 SC_TRACE_LOG = 752 SC_TRACE_NAME_MAX = 753 SC_TRACE_SYS_MAX = 754 SC_TRACE_USER_EVENT_MAX = 755 SC_TTY_NAME_MAX = 575 SC_TYPED_MEMORY_OBJECTS = 756 SC_TZNAME_MAX = 17 SC_V6_ILP32_OFF32 = 757 SC_V6_ILP32_OFFBIG = 758 SC_V6_LP64_OFF64 = 759 SC_V6_LPBIG_OFFBIG = 760 SC_VERSION = 8 SC_XBS5_ILP32_OFF32 = 720 SC_XBS5_ILP32_OFFBIG = 721 SC_XBS5_LP64_OFF64 = 722 SC_XBS5_LPBIG_OFFBIG = 723 SC_XOPEN_CRYPT = 62 SC_XOPEN_ENH_I18N = 63 SC_XOPEN_LEGACY = 717 SC_XOPEN_REALTIME = 718 SC_XOPEN_REALTIME_THREADS = 719 SC_XOPEN_SHM = 64 SC_XOPEN_STREAMS = 761 SC_XOPEN_UNIX = 78 SC_XOPEN_VERSION = 12 SC_XOPEN_XCU_VERSION = 67 end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-linux/errno.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-linux/errno.rb
# This file is generated by rake. Do not edit. module Platform; end module Platform::Errno E2BIG = 7 EACCES = 13 EADDRINUSE = 98 EADDRNOTAVAIL = 99 EAFNOSUPPORT = 97 EAGAIN = 11 EALREADY = 114 EBADF = 9 EBUSY = 16 ECHILD = 10 ECONNABORTED = 103 ECONNREFUSED = 111 ECONNRESET = 104 EDEADLK = 35 EDESTADDRREQ = 89 EEXIST = 17 EFAULT = 14 EFBIG = 27 EHOSTDOWN = 112 EHOSTUNREACH = 113 EINPROGRESS = 115 EINTR = 4 EINVAL = 22 EIO = 5 EISCONN = 106 EISDIR = 21 ELOOP = 40 EMFILE = 24 EMLINK = 31 EMSGSIZE = 90 ENAMETOOLONG = 36 ENETDOWN = 100 ENETRESET = 102 ENETUNREACH = 101 ENFILE = 23 ENOBUFS = 105 ENODEV = 19 ENOENT = 2 ENOEXEC = 8 ENOMEM = 12 ENOPROTOOPT = 92 ENOSPC = 28 ENOTCONN = 107 ENOTDIR = 20 ENOTEMPTY = 39 ENOTSOCK = 88 ENOTTY = 25 ENXIO = 6 EOPNOTSUPP = 95 EPERM = 1 EPIPE = 32 EPROTONOSUPPORT = 93 EPROTOTYPE = 91 EROFS = 30 ESPIPE = 29 ESRCH = 3 ETIMEDOUT = 110 ETXTBSY = 26 EWOULDBLOCK = 11 EXDEV = 18 end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-linux/socket.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-linux/socket.rb
# This file is generated by rake. Do not edit. module Platform; end module Platform::Socket AF_APPLETALK = 5 # AF_ATM not available AF_AX25 = 3 # AF_CCITT not available # AF_CHAOS not available # AF_CNT not available # AF_COIP not available # AF_DATAKIT not available AF_DECnet = 12 # AF_DLI not available # AF_E164 not available # AF_ECMA not available # AF_HYLINK not available # AF_IMPLINK not available AF_INET = 2 AF_INET6 = 10 AF_IPX = 4 # AF_ISDN not available # AF_ISO not available # AF_LAT not available # AF_LINK not available AF_LOCAL = 1 AF_MAX = 34 # AF_NATM not available # AF_NDRV not available # AF_NETBIOS not available # AF_NETGRAPH not available # AF_NS not available # AF_OSI not available # AF_PPP not available # AF_PUP not available AF_ROUTE = 16 # AF_SIP not available AF_SNA = 22 # AF_SYSTEM not available AF_UNIX = 1 AF_UNSPEC = 0 NI_DGRAM = 16 # NI_FQDN_FLAG_VALIDTTL not available NI_MAXHOST = 1025 NI_MAXSERV = 32 NI_NAMEREQD = 8 # NI_NODEADDR_FLAG_ALL not available # NI_NODEADDR_FLAG_ANYCAST not available # NI_NODEADDR_FLAG_COMPAT not available # NI_NODEADDR_FLAG_GLOBAL not available # NI_NODEADDR_FLAG_LINKLOCAL not available # NI_NODEADDR_FLAG_SITELOCAL not available # NI_NODEADDR_FLAG_TRUNCATE not available NI_NOFQDN = 4 NI_NUMERICHOST = 1 NI_NUMERICSERV = 2 # NI_QTYPE_DNSNAME not available # NI_QTYPE_FQDN not available # NI_QTYPE_IPV4ADDR not available # NI_QTYPE_NODEADDR not available # NI_QTYPE_NOOP not available # NI_QTYPE_SUPTYPES not available # NI_SUPTYPE_FLAG_COMPRESS not available # NI_WITHSCOPEID not available PF_APPLETALK = 5 # PF_ATM not available # PF_CCITT not available # PF_CHAOS not available # PF_CNT not available # PF_COIP not available # PF_DATAKIT not available PF_DECnet = 12 # PF_DLI not available # PF_ECMA not available # PF_HYLINK not available # PF_IMPLINK not available PF_INET = 2 PF_INET6 = 10 PF_IPX = 4 # PF_ISDN not available # PF_ISO not available PF_KEY = 15 # PF_LAT not available # PF_LINK not available PF_LOCAL = 1 PF_MAX = 34 # PF_NATM not available # PF_NDRV not available # PF_NETBIOS not available # PF_NETGRAPH not available # PF_NS not available # PF_OSI not available # PF_PIP not available # PF_PPP not available # PF_PUP not available PF_ROUTE = 16 # PF_RTIP not available # PF_SIP not available PF_SNA = 22 # PF_SYSTEM not available PF_UNIX = 1 PF_UNSPEC = 0 # PF_XTP not available SOCK_DGRAM = 2 # SOCK_MAXADDRLEN not available SOCK_RAW = 3 SOCK_RDM = 4 SOCK_SEQPACKET = 5 SOCK_STREAM = 1 SO_ACCEPTCONN = 30 # SO_ACCEPTFILTER not available SO_ATTACH_FILTER = 26 SO_BINDTODEVICE = 25 SO_BROADCAST = 6 SO_DEBUG = 1 SO_DETACH_FILTER = 27 SO_DONTROUTE = 5 # SO_DONTTRUNC not available SO_ERROR = 4 SO_KEEPALIVE = 9 # SO_LABEL not available SO_LINGER = 13 # SO_NKE not available # SO_NOADDRERR not available # SO_NOSIGPIPE not available SO_NO_CHECK = 11 # SO_NREAD not available # SO_NWRITE not available SO_OOBINLINE = 10 SO_PASSCRED = 16 SO_PEERCRED = 17 # SO_PEERLABEL not available SO_PEERNAME = 28 SO_PRIORITY = 12 SO_RCVBUF = 8 SO_RCVLOWAT = 18 SO_RCVTIMEO = 20 SO_REUSEADDR = 2 # SO_REUSEPORT not available # SO_REUSESHAREUID not available SO_SECURITY_AUTHENTICATION = 22 SO_SECURITY_ENCRYPTION_NETWORK = 24 SO_SECURITY_ENCRYPTION_TRANSPORT = 23 SO_SNDBUF = 7 SO_SNDLOWAT = 19 SO_SNDTIMEO = 21 SO_TIMESTAMP = 29 SO_TYPE = 3 # SO_USELOOPBACK not available # SO_WANTMORE not available # SO_WANTOOBFLAG not available # pseudo_AF_HDRCMPLT not available # pseudo_AF_KEY not available # pseudo_AF_PIP not available # pseudo_AF_RTIP not available # pseudo_AF_XTP not available end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-linux/stat.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-linux/stat.rb
# This file is generated by rake. Do not edit. module Platform module Stat class Stat < FFI::Struct self.size = 96 layout :st_dev, :dev_t, 0, :st_ino, :ino_t, 88, :st_nlink, :nlink_t, 20, :st_mode, :mode_t, 16, :st_uid, :uid_t, 24, :st_gid, :gid_t, 28, :st_size, :off_t, 44, :st_blocks, :blkcnt_t, 56, :st_atime, :time_t, 64, :st_mtime, :time_t, 72, :st_ctime, :time_t, 80 end module Constants S_IEXEC = 0x40 S_IREAD = 0x100 S_IRGRP = 0x20 S_IROTH = 0x4 S_IRUSR = 0x100 S_IRWXG = 0x38 S_IRWXO = 0x7 S_IRWXU = 0x1c0 S_ISGID = 0x400 S_ISUID = 0x800 S_IWGRP = 0x10 S_IWOTH = 0x2 S_IWRITE = 0x80 S_IWUSR = 0x80 S_IXGRP = 0x8 S_IXOTH = 0x1 S_IXUSR = 0x40 end include Constants end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-linux/etc.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-linux/etc.rb
# This file is generated by rake. Do not edit. module Platform; end module Platform::Etc class Passwd < FFI::Struct self.size = 28 layout :pw_name, :string, 0, :pw_passwd, :string, 4, :pw_uid, :uint, 8, :pw_gid, :uint, 12, :pw_dir, :string, 20, :pw_shell, :string, 24 end class Group < FFI::Struct self.size = 16 layout :gr_name, :string, 0, :gr_gid, :uint, 8 end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-linux/syslog.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-linux/syslog.rb
# This file is generated by rake. Do not edit. module Syslog module Constants LOG_ALERT = 1 LOG_AUTH = 32 LOG_AUTHPRIV = 80 LOG_CONS = 2 # LOG_CONSOLE not available LOG_CRIT = 2 LOG_CRON = 72 LOG_DAEMON = 24 LOG_DEBUG = 7 LOG_EMERG = 0 LOG_ERR = 3 LOG_FTP = 88 LOG_INFO = 6 LOG_KERN = 0 LOG_LOCAL0 = 128 LOG_LOCAL1 = 136 LOG_LOCAL2 = 144 LOG_LOCAL3 = 152 LOG_LOCAL4 = 160 LOG_LOCAL5 = 168 LOG_LOCAL6 = 176 LOG_LOCAL7 = 184 LOG_LPR = 48 LOG_MAIL = 16 LOG_NEWS = 56 # LOG_NODELAY not available LOG_NOTICE = 5 LOG_NOWAIT = 16 # LOG_NTP not available LOG_ODELAY = 4 LOG_PERROR = 32 LOG_PID = 1 # LOG_SECURITY not available LOG_SYSLOG = 40 LOG_USER = 8 LOG_UUCP = 64 LOG_WARNING = 4 end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-linux/fcntl.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-linux/fcntl.rb
# This file is generated by rake. Do not edit. module Fcntl FD_CLOEXEC = 1 F_DUPFD = 0 F_GETFD = 1 F_GETFL = 3 F_GETLK = 12 F_RDLCK = 0 F_SETFD = 2 F_SETFL = 4 F_SETLK = 13 F_SETLKW = 14 F_UNLCK = 2 F_WRLCK = 1 O_ACCMODE = 3 O_APPEND = 1024 O_CREAT = 64 O_EXCL = 128 O_NDELAY = 2048 O_NOCTTY = 256 O_NONBLOCK = 2048 O_RDONLY = 0 O_RDWR = 2 O_TRUNC = 512 O_WRONLY = 1 end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-linux/zlib.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-linux/zlib.rb
# This file is generated by rake. Do not edit. ## # The Zlib module contains several classes for compressing and decompressing # streams, and for working with "gzip" files. # # == Classes # # Following are the classes that are most likely to be of interest to the # user: # - Zlib::Inflate # - Zlib::Deflate # - Zlib::GzipReader # - Zlib::GzipWriter # # There are two important base classes for the classes above: Zlib::ZStream # and Zlib::GzipFile. Everything else is an error class. # # == Constants # # Here's a list. # # Zlib::VERSION # The Ruby/zlib version string. # # Zlib::ZLIB_VERSION # The string which represents the version of zlib.h. # # Zlib::BINARY # Zlib::ASCII # Zlib::UNKNOWN # The integers representing data types which Zlib::ZStream#data_type # method returns. # # Zlib::NO_COMPRESSION # Zlib::BEST_SPEED # Zlib::BEST_COMPRESSION # Zlib::DEFAULT_COMPRESSION # The integers representing compression levels which are an argument # for Zlib::Deflate.new, Zlib::Deflate#deflate, and so on. # # Zlib::FILTERED # Zlib::HUFFMAN_ONLY # Zlib::DEFAULT_STRATEGY # The integers representing compression methods which are an argument # for Zlib::Deflate.new and Zlib::Deflate#params. # # Zlib::DEF_MEM_LEVEL # Zlib::MAX_MEM_LEVEL # The integers representing memory levels which are an argument for # Zlib::Deflate.new, Zlib::Deflate#params, and so on. # # Zlib::MAX_WBITS # The default value of windowBits which is an argument for # Zlib::Deflate.new and Zlib::Inflate.new. # # Zlib::NO_FLUSH # Zlib::SYNC_FLUSH # Zlib::FULL_FLUSH # Zlib::FINISH # The integers to control the output of the deflate stream, which are # an argument for Zlib::Deflate#deflate and so on. #-- # These constants are missing! # # Zlib::OS_CODE # Zlib::OS_MSDOS # Zlib::OS_AMIGA # Zlib::OS_VMS # Zlib::OS_UNIX # Zlib::OS_VMCMS # Zlib::OS_ATARI # Zlib::OS_OS2 # Zlib::OS_MACOS # Zlib::OS_ZSYSTEM # Zlib::OS_CPM # Zlib::OS_TOPS20 # Zlib::OS_WIN32 # Zlib::OS_QDOS # Zlib::OS_RISCOS # Zlib::OS_UNKNOWN # The return values of Zlib::GzipFile#os_code method. module Zlib ZLIB_VERSION = "1.2.3.3" BEST_COMPRESSION = 9 BEST_SPEED = 1 BLOCK = 5 BUF_ERROR = -5 DATA_ERROR = -3 DEFAULT_COMPRESSION = -1 DEFAULT_STRATEGY = 0 DEFLATED = 8 ERRNO = -1 FILTERED = 1 FINISH = 4 FIXED = 4 FULL_FLUSH = 3 HUFFMAN_ONLY = 2 MEM_ERROR = -4 NEED_DICT = 2 NO_COMPRESSION = 0 NO_FLUSH = 0 OK = 0 PARTIAL_FLUSH = 1 RLE = 3 STREAM_END = 1 STREAM_ERROR = -2 SYNC_FLUSH = 2 VERSION_ERROR = -6 # DEF_MEM_LEVEL not available MAX_MEM_LEVEL = 9 MAX_WBITS = 15 OS_MSDOS = 0x00 OS_AMIGA = 0x01 OS_VMS = 0x02 OS_UNIX = 0x03 OS_ATARI = 0x05 OS_OS2 = 0x06 OS_MACOS = 0x07 OS_TOPS20 = 0x0a OS_WIN32 = 0x0b OS_VMCMS = 0x04 OS_ZSYSTEM = 0x08 OS_CPM = 0x09 OS_QDOS = 0x0c OS_RISCOS = 0x0d OS_UNKNOWN = 0xff # OS_CODE not available unless defined? OS_CODE then OS_CODE = OS_UNIX end # from zutil.h unless defined? DEF_MEM_LEVEL then DEF_MEM_LEVEL = MAX_MEM_LEVEL >= 8 ? 8 : MAX_MEM_LEVEL end class Error < StandardError; end class StreamEnd < Error; end class NeedDict < Error; end class StreamError < Error; end class DataError < Error; end class BufError < Error; end class VersionError < Error; end class MemError < Error; end ## # Zlib::ZStream is the abstract class for the stream which handles the # compressed data. The operations are defined in the subclasses: # Zlib::Deflate for compression, and Zlib::Inflate for decompression. # # An instance of Zlib::ZStream has one stream (struct zstream in the source) # and two variable-length buffers which associated to the input (next_in) of # the stream and the output (next_out) of the stream. In this document, # "input buffer" means the buffer for input, and "output buffer" means the # buffer for output. # # Data input into an instance of Zlib::ZStream are temporally stored into # the end of input buffer, and then data in input buffer are processed from # the beginning of the buffer until no more output from the stream is # produced (i.e. until avail_out > 0 after processing). During processing, # output buffer is allocated and expanded automatically to hold all output # data. # # Some particular instance methods consume the data in output buffer and # return them as a String. # # Here is an ascii art for describing above: # # +================ an instance of Zlib::ZStream ================+ # || || # || +--------+ +-------+ +--------+ || # || +--| output |<---------|zstream|<---------| input |<--+ || # || | | buffer | next_out+-------+next_in | buffer | | || # || | +--------+ +--------+ | || # || | | || # +===|======================================================|===+ # | | # v | # "output data" "input data" # # If an error occurs during processing input buffer, an exception which is a # subclass of Zlib::Error is raised. At that time, both input and output # buffer keep their conditions at the time when the error occurs. # # == Method Catalogue # # Many of the methods in this class are fairly low-level and unlikely to be # of interest to users. In fact, users are unlikely to use this class # directly; rather they will be interested in Zlib::Inflate and # Zlib::Deflate. # # The higher level methods are listed below. # # - #total_in # - #total_out # - #data_type # - #adler # - #reset # - #finish # - #finished? # - #close # - #closed? class ZStream < FFI::Struct self.size = 56 layout :next_in, :pointer, 0, :avail_in, :uint, 4, :total_in, :ulong, 8, :next_out, :pointer, 12, :avail_out, :uint, 16, :total_out, :ulong, 20, :msg, :string, 24, :state, :pointer, 28, :zalloc, :pointer, 32, :zfree, :pointer, 36, :opaque, :pointer, 40, :data_type, :int, 44, :adler, :ulong, 48, :reserved, :ulong, 52 #-- # HACK from MRI's zlib.c #++ READY = 0x1 IN_STREAM = 0x2 FINISHED = 0x4 CLOSING = 0x8 UNUSED = 0x10 attr_accessor :flags attr_reader :input attr_reader :output def self.inherited(subclass) subclass.instance_variable_set :@layout, @layout subclass.instance_variable_set :@size, @size end def initialize super self[:avail_in] = 0 self[:avail_out] = 0 self[:next_in] = nil self[:opaque] = nil self[:zalloc] = nil self[:zfree] = nil reset_input @output = nil @flags = 0 @func = nil end def closing? @flags & CLOSING == CLOSING end def detatch_output if @output.nil? then data = '' else data = @output @output = nil self[:avail_out] = 0 self[:next_out] = nil end data end ## # Closes the stream. All operations on the closed stream will raise an # exception. def end unless ready? then warn "attempt to close uninitialized stream; ignored." return nil end if in_stream? then warn "attempt to close unfinished zstream; reset forced" reset end reset_input err = Zlib.send @func_end, pointer Zlib.handle_error err, message @flags = 0 # HACK this may be wrong @output = nil @next_out.free unless @next_out.nil? @next_out = nil nil end alias :close :end def expand_output if @output.nil? then @output = '' @next_out = MemoryPointer.new CHUNK if @next_out.nil? @next_out.write_string "\000" * CHUNK self[:next_out] = @next_out else have = CHUNK - self[:avail_out] @output << @next_out.read_string(have) self[:next_out] = @next_out # Zlib advances self[:next_out] end self[:avail_out] = CHUNK end ## # Finishes the stream and flushes output buffer. See Zlib::Deflate#finish # and Zlib::Inflate#finish for details of this behavior. def finish run '', Zlib::FINISH detatch_output end ## # Returns true if the stream is finished. def finished? @flags & FINISHED == FINISHED end ## # Flushes output buffer and returns all data in that buffer. def flush_next_out detatch_output end def in_stream? @flags & IN_STREAM == IN_STREAM end def input_empty? @input.nil? or @input.empty? end ## # The msg field of the struct def message self[:msg] end def ready @flags |= READY end def ready? @flags & READY == READY end ## # Resets and initializes the stream. All data in both input and output # buffer are discarded. def reset err = Zlib.send @func_reset, pointer Zlib.handle_error err, message @flags = READY reset_input end def reset_input @input = nil end def run(data, flush) if @input.nil? and data.empty? then data_in = MemoryPointer.new 1 data_in.write_string "\000", 1 self[:next_in] = data_in self[:avail_in] = 0 else @input ||= '' @input << data data_in = MemoryPointer.new @input.length data_in.write_string @input, @input.length self[:next_in] = data_in self[:avail_in] = @input.length end expand_output if self[:avail_out] == 0 loop do err = Zlib.send @func_run, pointer, flush available = self[:avail_out] expand_output # HACK does this work when err is set? if err == Zlib::STREAM_END then @flags &= ~IN_STREAM @flags |= FINISHED break end unless err == Zlib::OK then if flush != Zlib::FINISH and err == Zlib::BUF_ERROR and self[:avail_out] > 0 then @flags |= IN_STREAM break end if self[:avail_in] > 0 then @input = self[:next_in].read_string(self[:avail_in]) + @input end Zlib.handle_error err, message end if available > 0 then @flags |= IN_STREAM break end end reset_input if self[:avail_in] > 0 then @input = self[:next_in].read_string self[:avail_in] end ensure data_in.free self[:next_in] = nil end ## # Returns the number of bytes consumed def total_in self[:total_in] end ## # Returns the number bytes processed def total_out self[:total_out] end end set_ffi_lib 'libz' # deflateInit2 is a macro pointing to deflateInit2_ attach_function :deflateInit2_, [ :pointer, # z_streamp strm :int, # int level :int, # int method :int, # int windowBits :int, # int memLevel :int, # int strategy :string, # ZLIB_VERSION :int # (int)sizeof(z_stream) ], :int def self.deflateInit2(stream, level, method, window_bits, mem_level, strategy) deflateInit2_ stream, level, method, window_bits, mem_level, strategy, ZLIB_VERSION, ZStream.size end attach_function :deflate, [:pointer, :int], :int attach_function :deflateEnd, [:pointer], :int attach_function :deflateParams, [:pointer, :int, :int], :int attach_function :deflateReset, [:pointer], :int attach_function :deflateSetDictionary, [:pointer, :string, :uint], :int # inflateInit2 is a macro pointing to inflateInit2_ attach_function :inflateInit2_, [:pointer, :int, :string, :int], :int def self.inflateInit2(stream, window_bits) inflateInit2_ stream, window_bits, ZLIB_VERSION, ZStream.size end attach_function :inflate, [:pointer, :int], :int attach_function :inflateEnd, [:pointer], :int attach_function :inflateReset, [:pointer], :int attach_function :inflateSetDictionary, [:pointer, :string, :uint], :int attach_function :adler32_c, :adler32, [:ulong, :string, :uint], :ulong attach_function :crc32_c, :crc32, [:ulong, :string, :uint], :ulong attach_function :get_crc_table_c, :get_crc_table, [], :pointer attach_function :zError, [:int], :string # Chunk size for inflation and deflation CHUNK = 1024 #-- # HACK from zlib.c #++ GZ_EXTRAFLAG_FAST = 0x4 GZ_EXTRAFLAG_SLOW = 0x2 ## # Zlib::Deflate is the class for compressing data. See Zlib::ZStream for # more information. class Deflate < ZStream ## # Compresses the given +string+. Valid values of level are # <tt>Zlib::NO_COMPRESSION</tt>, <tt>Zlib::BEST_SPEED</tt>, # <tt>Zlib::BEST_COMPRESSION</tt>, <tt>Zlib::DEFAULT_COMPRESSION</tt>, and # an integer from 0 to 9. # # This method is almost equivalent to the following code: # # def deflate(string, level) # z = Zlib::Deflate.new(level) # dst = z.deflate(string, Zlib::FINISH) # z.close # dst # end def self.deflate(data, level = Zlib::DEFAULT_COMPRESSION) deflator = new level zipped = deflator.deflate data, Zlib::FINISH zipped ensure deflator.end end ## # Creates a new deflate stream for compression. See zlib.h for details of # each argument. If an argument is nil, the default value of that argument # is used. def initialize(level = Zlib::DEFAULT_COMPRESSION, window_bits = Zlib::MAX_WBITS, mem_level = Zlib::DEF_MEM_LEVEL, strategy = Zlib::DEFAULT_STRATEGY) level ||= Zlib::DEFAULT_COMPRESSION window_bits ||= Zlib::MAX_WBITS mem_level ||= Zlib::DEF_MEM_LEVEL strategy ||= Zlib::DEFAULT_STRATEGY super() @func_end = :deflateEnd @func_reset = :deflateReset @func_run = :deflate err = Zlib.deflateInit2(pointer, level, Zlib::DEFLATED, window_bits, mem_level, strategy) Zlib.handle_error err, message ready end ## # Same as IO. def <<(data) do_deflate data, Zlib::NO_FLUSH self end ## # Inputs +string+ into the deflate stream and returns the output from the # stream. On calling this method, both the input and the output buffers # of the stream are flushed. If +string+ is nil, this method finishes the # stream, just like Zlib::ZStream#finish. # # The value of +flush+ should be either <tt>Zlib::NO_FLUSH</tt>, # <tt>Zlib::SYNC_FLUSH</tt>, <tt>Zlib::FULL_FLUSH</tt>, or # <tt>Zlib::FINISH</tt>. See zlib.h for details. def deflate(data, flush = Zlib::NO_FLUSH) do_deflate data, flush detatch_output end ## # Performs the deflate operation and leaves the compressed data in the # output buffer def do_deflate(data, flush) if data.nil? then run '', Zlib::FINISH else data = StringValue data if flush != Zlib::NO_FLUSH or not data.empty? then # prevent BUF_ERROR run data, flush end end end ## # Finishes compressing the deflate input stream and returns the output # buffer. def finish run '', Zlib::FINISH detatch_output end ## # This method is equivalent to <tt>deflate('', flush)</tt>. If flush is # omitted, <tt>Zlib::SYNC_FLUSH</tt> is used as flush. This method is # just provided to improve the readability of your Ruby program. def flush(flush = Zlib::SYNC_FLUSH) run '', flush unless flush == Zlib::NO_FLUSH detatch_output end ## # Changes the parameters of the deflate stream. See zlib.h for details. # The output from the stream by changing the params is preserved in output # buffer. def params(level, strategy) err = Zlib.deflateParams pointer, level, strategy raise Zlib::BufError, 'buffer expansion not implemented' if err == Zlib::BUF_ERROR Zlib.handle_error err, message nil end ## # Sets the preset dictionary and returns +dictionary+. This method is # available just only after Zlib::Deflate.new or Zlib::ZStream#reset # method was called. See zlib.h for details. def set_dictionary(dictionary) dict = StringValue dictionary err = Zlib.deflateSetDictionary pointer, dict, dict.length Zlib.handle_error err, message dictionary end end ## # Zlib::GzipFile is an abstract class for handling a gzip formatted # compressed file. The operations are defined in the subclasses, # Zlib::GzipReader for reading, and Zlib::GzipWriter for writing. # # GzipReader should be used by associating an IO, or IO-like, object. class GzipFile SYNC = Zlib::ZStream::UNUSED HEADER_FINISHED = Zlib::ZStream::UNUSED << 1 FOOTER_FINISHED = Zlib::ZStream::UNUSED << 2 FLAG_MULTIPART = 0x2 FLAG_EXTRA = 0x4 FLAG_ORIG_NAME = 0x8 FLAG_COMMENT = 0x10 FLAG_ENCRYPT = 0x20 FLAG_UNKNOWN_MASK = 0xc0 EXTRAFLAG_FAST = 0x4 EXTRAFLAG_SLOW = 0x2 MAGIC1 = 0x1f MAGIC2 = 0x8b METHOD_DEFLATE = 8 ## # Base class of errors that occur when processing GZIP files. class Error < Zlib::Error; end ## # Raised when gzip file footer is not found. class NoFooter < Error; end ## # Raised when the CRC checksum recorded in gzip file footer is not # equivalent to the CRC checksum of the actual uncompressed data. class CRCError < Error; end ## # Raised when the data length recorded in the gzip file footer is not # equivalent to the length of the actual uncompressed data. class LengthError < Error; end ## # Accessor for the underlying ZStream attr_reader :zstream # :nodoc: ## # See Zlib::GzipReader#wrap and Zlib::GzipWriter#wrap. def self.wrap(*args) obj = new(*args) if block_given? then begin yield obj ensure obj.close if obj.zstream.ready? end end end def initialize @comment = nil @crc = 0 @level = nil @mtime = Time.at 0 @orig_name = nil @os_code = Zlib::OS_CODE end ## # Closes the GzipFile object. This method calls close method of the # associated IO object. Returns the associated IO object. def close io = finish io.close if io.respond_to? :close io end ## # Same as IO def closed? @io.nil? end ## # Returns comments recorded in the gzip file header, or nil if the # comment is not present. def comment raise Error, 'closed gzip stream' if @io.nil? @comment.dup end def end return if @zstream.closing? @zstream.flags |= Zlib::ZStream::CLOSING begin end_run ensure @zstream.end end end ## # Closes the GzipFile object. Unlike Zlib::GzipFile#close, this method # never calls the close method of the associated IO object. Returns the # associated IO object. def finish self.end io = @io @io = nil @orig_name = nil @comment = nil io end def finished? @zstream.finished? and @zstream.output.empty? # HACK I think end def footer_finished? @zstream.flags & Zlib::GzipFile::FOOTER_FINISHED == Zlib::GzipFile::FOOTER_FINISHED end def header_finished? @zstream.flags & Zlib::GzipFile::HEADER_FINISHED == Zlib::GzipFile::HEADER_FINISHED end ## # Returns last modification time recorded in the gzip file header. def mtime Time.at @mtime end ## # Returns original filename recorded in the gzip file header, or +nil+ if # original filename is not present. def orig_name raise Error, 'closed gzip stream' if @io.nil? @orig_name.dup end end ## # Zlib::GzipReader is the class for reading a gzipped file. GzipReader # should be used an IO, or -IO-lie, object. # # Zlib::GzipReader.open('hoge.gz') {|gz| # print gz.read # } # # File.open('hoge.gz') do |f| # gz = Zlib::GzipReader.new(f) # print gz.read # gz.close # end # # == Method Catalogue # # The following methods in Zlib::GzipReader are just like their counterparts # in IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an # error was found in the gzip file. # # - #each # - #each_line # - #each_byte # - #gets # - #getc # - #lineno # - #lineno= # - #read # - #readchar # - #readline # - #readlines # - #ungetc # # Be careful of the footer of the gzip file. A gzip file has the checksum of # pre-compressed data in its footer. GzipReader checks all uncompressed data # against that checksum at the following cases, and if it fails, raises # <tt>Zlib::GzipFile::NoFooter</tt>, <tt>Zlib::GzipFile::CRCError</tt>, or # <tt>Zlib::GzipFile::LengthError</tt> exception. # # - When an reading request is received beyond the end of file (the end of # compressed data). That is, when Zlib::GzipReader#read, # Zlib::GzipReader#gets, or some other methods for reading returns nil. # - When Zlib::GzipFile#close method is called after the object reaches the # end of file. # - When Zlib::GzipReader#unused method is called after the object reaches # the end of file. # # The rest of the methods are adequately described in their own # documentation. class GzipReader < GzipFile # HACK use a buffer class ## # Creates a GzipReader object associated with +io+. The GzipReader object # reads gzipped data from +io+, and parses/decompresses them. At least, # +io+ must have a +read+ method that behaves same as the +read+ method in # IO class. # # If the gzip file header is incorrect, raises an Zlib::GzipFile::Error # exception. def initialize(io) @io = io @zstream = Zlib::Inflate.new -Zlib::MAX_WBITS @buffer = '' super() read_header end def check_footer @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED footer = @zstream.input.slice! 0, 8 rest = @io.read 8 - footer.length footer << rest if rest raise NoFooter, 'footer is not found' unless footer.length == 8 crc, length = footer.unpack 'VV' @zstream[:total_in] += 8 # to rewind correctly raise CRCError, 'invalid compressed data -- crc error' unless @crc == crc raise LengthError, 'invalid compressed data -- length error' unless length == @zstream.total_out end def end_run check_footer if @zstream.finished? and not footer_finished? end def eof? @zstream.finished? and @zstream.input_empty? end def pos @zstream[:total_out] - @buffer.length end ## # See Zlib::GzipReader documentation for a description. def read(length = nil) data = @buffer while chunk = @io.read(CHUNK) do inflated = @zstream.inflate(chunk) @crc = Zlib.crc32 inflated, @crc data << inflated break if length and data.length > length end if length then @buffer = data.slice! length..-1 else @buffer = '' end check_footer if @zstream.finished? and not footer_finished? data rescue Zlib::Error => e raise GzipFile::Error, e.message end def read_header header = @io.read 10 raise Error, 'not in gzip format' unless header.length == 10 magic1, magic2, method, flags, @mtime, extra_flags, @os_code = header.unpack 'CCCCVCC' unless magic1 == Zlib::GzipFile::MAGIC1 and magic2 == Zlib::GzipFile::MAGIC2 then raise Error, 'not in gzip format' end unless method == Zlib::GzipFile::METHOD_DEFLATE then raise Error, "unsupported compression method #{method}" end if flags & Zlib::GzipFile::FLAG_MULTIPART == Zlib::GzipFile::FLAG_MULTIPART then raise Error, 'multi-part gzip file is not supported' end if flags & Zlib::GzipFile::FLAG_ENCRYPT == Zlib::GzipFile::FLAG_ENCRYPT then raise Error, 'encrypted gzip file is not supported' end if flags & Zlib::GzipFile::FLAG_UNKNOWN_MASK == Zlib::GzipFile::FLAG_UNKNOWN_MASK then raise Error, "unknown flags 0x#{flags.to_s 16}" end if extra_flags & Zlib::GzipFile::EXTRAFLAG_FAST == Zlib::GzipFile::EXTRAFLAG_FAST then @level = Zlib::BEST_SPEED elsif extra_flags & Zlib::GzipFile::EXTRAFLAG_SLOW == Zlib::GzipFile::EXTRAFLAG_SLOW then @level = Zlib::BEST_COMPRESSION else @level = Zlib::DEFAULT_COMPRESSION end if flags & Zlib::GzipFile::FLAG_EXTRA == Zlib::GzipFile::FLAG_EXTRA then length = @io.read 2 raise Zlib::GzipFile::Error, 'unexpected end of file' if length.nil? or length.length != 2 length, = length.unpack 'v' extra = @io.read length + 2 raise Zlib::GzipFile::Error, 'unexpected end of file' if extra.nil? or extra.length != length + 2 end if flags & Zlib::GzipFile::FLAG_ORIG_NAME == Zlib::GzipFile::FLAG_ORIG_NAME then @orig_name = '' c = @io.getc until c == 0 do @orig_name << c.chr c = @io.getc end end if flags & Zlib::GzipFile::FLAG_COMMENT == Zlib::GzipFile::FLAG_COMMENT then @comment = '' c = @io.getc until c == 0 do @comment << c.chr c = @io.getc end end end end ## # Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should # be used with an instance of IO, or IO-like, object. # # For example: # # Zlib::GzipWriter.open('hoge.gz') do |gz| # gz.write 'jugemu jugemu gokou no surikire...' # end # # File.open('hoge.gz', 'w') do |f| # gz = Zlib::GzipWriter.new(f) # gz.write 'jugemu jugemu gokou no surikire...' # gz.close # end # # NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close # GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter # will be not able to write the gzip footer and will generate a broken gzip # file. class GzipWriter < GzipFile # HACK use a buffer class ## # Set the comment attr_writer :comment ## # Set the original name attr_writer :orig_name ## # Creates a GzipWriter object associated with +io+. +level+ and +strategy+ # should be the same as the arguments of Zlib::Deflate.new. The # GzipWriter object writes gzipped data to +io+. At least, +io+ must # respond to the +write+ method that behaves same as write method in IO # class. def initialize(io, level = Zlib::DEFAULT_COMPRESSION, strategy = Zlib::DEFAULT_STRATEGY) @io = io @zstream = Zlib::Deflate.new level, -Zlib::MAX_WBITS, Zlib::DEF_MEM_LEVEL, strategy @buffer = '' super() end def end_run make_header unless header_finished? @zstream.run '', Zlib::FINISH write_raw make_footer nil end ## # Flushes all the internal buffers of the GzipWriter object. The meaning # of +flush+ is same as in Zlib::Deflate#deflate. # <tt>Zlib::SYNC_FLUSH</tt> is used if +flush+ is omitted. It is no use # giving flush <tt>Zlib::NO_FLUSH</tt>. def flush true end ## # Writes out a gzip header def make_header flags = 0 extra_flags = 0 flags |= Zlib::GzipFile::FLAG_ORIG_NAME if @orig_name flags |= Zlib::GzipFile::FLAG_COMMENT if @comment extra_flags |= Zlib::GzipFile::EXTRAFLAG_FAST if @level == Zlib::BEST_SPEED extra_flags |= Zlib::GzipFile::EXTRAFLAG_SLOW if @level == Zlib::BEST_COMPRESSION header = [ Zlib::GzipFile::MAGIC1, # byte 0 Zlib::GzipFile::MAGIC2, # byte 1 Zlib::GzipFile::METHOD_DEFLATE, # byte 2 flags, # byte 3 @mtime.to_i, # bytes 4-7 extra_flags, # byte 8 @os_code # byte 9 ].pack 'CCCCVCC' @io.write header @io.write "#{@orig_name}\0" if @orig_name @io.write "#{@comment}\0" if @comment @zstream.flags |= Zlib::GzipFile::HEADER_FINISHED end ## # Writes out a gzip footer def make_footer footer = [ @crc, # bytes 0-3 @zstream.total_in, # bytes 4-7 ].pack 'VV' @io.write footer @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED end ## # Sets the modification time of this file def mtime=(time) if header_finished? then raise Zlib::GzipFile::Error, 'header is already written' end @mtime = Integer time end def sync? @zstream.flags & Zlib::GzipFile::SYNC == Zlib::GzipFile::SYNC end ## # Same as IO. def write(data) make_header unless header_finished? data = String data if data.length > 0 or sync? then @crc = Zlib.crc32_c @crc, data, data.length flush = sync? ? Zlib::SYNC_FLUSH : Zlib::NO_FLUSH @zstream.run data, flush end write_raw end ## # Same as IO. alias << write def write_raw data = @zstream.detatch_output unless data.empty? then @io.write data @io.flush if sync? and io.respond_to :flush end end end ## # Zlib:Inflate is the class for decompressing compressed data. Unlike # Zlib::Deflate, an instance of this class is not able to duplicate (clone, # dup) itself. class Inflate < ZStream ## # Decompresses +string+. Raises a Zlib::NeedDict exception if a preset # dictionary is needed for decompression. # # This method is almost equivalent to the following code: # # def inflate(string) # zstream = Zlib::Inflate.new # buf = zstream.inflate(string) # zstream.finish # zstream.close # buf # end def self.inflate(data) inflator = new unzipped = inflator.inflate data unzipped ensure inflator.end end ## # Creates a new inflate stream for decompression. See zlib.h for details # of the argument. If +window_bits+ is +nil+, the default value is used. def initialize(window_bits = Zlib::MAX_WBITS) super() @func_end = :inflateEnd @func_reset = :inflateReset @func_run = :inflate err = Zlib.inflateInit2 pointer, window_bits Zlib.handle_error err, message # HACK ready end ## # Inputs +string+ into the inflate stream just like Zlib::Inflate#inflate, # but returns the Zlib::Inflate object itself. The output from the stream # is preserved in output buffer. def <<(string) string = StringValue string unless string.nil? if finished? then unless string.nil? then @input ||= '' @input << string end else run string, Zlib::SYNC_FLUSH end end ## # Inputs +string+ into the inflate stream and returns the output from the # stream. Calling this method, both the input and the output buffer of # the stream are flushed. If string is +nil+, this method finishes the
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
true
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-linux/sysconf.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-linux/sysconf.rb
# This file is generated by rake. Do not edit. module Platform;end module Platform::Sysconf SC_2_CHAR_TERM = 95 SC_2_C_BIND = 47 SC_2_C_DEV = 48 SC_2_FORT_DEV = 49 SC_2_FORT_RUN = 50 SC_2_LOCALEDEF = 52 SC_2_PBS = 168 SC_2_PBS_ACCOUNTING = 169 SC_2_PBS_CHECKPOINT = 175 SC_2_PBS_LOCATE = 170 SC_2_PBS_MESSAGE = 171 SC_2_PBS_TRACK = 172 SC_2_SW_DEV = 51 SC_2_UPE = 97 SC_2_VERSION = 46 SC_ADVISORY_INFO = 132 SC_AIO_LISTIO_MAX = 23 SC_AIO_MAX = 24 SC_AIO_PRIO_DELTA_MAX = 25 SC_ARG_MAX = 0 SC_ASYNCHRONOUS_IO = 12 SC_ATEXIT_MAX = 87 SC_BARRIERS = 133 SC_BC_BASE_MAX = 36 SC_BC_DIM_MAX = 37 SC_BC_SCALE_MAX = 38 SC_BC_STRING_MAX = 39 SC_CHILD_MAX = 1 SC_CLK_TCK = 2 SC_CLOCK_SELECTION = 137 SC_COLL_WEIGHTS_MAX = 40 SC_CPUTIME = 138 SC_DELAYTIMER_MAX = 26 SC_EXPR_NEST_MAX = 42 SC_FILE_LOCKING = 147 SC_FSYNC = 15 SC_GETGR_R_SIZE_MAX = 69 SC_GETPW_R_SIZE_MAX = 70 SC_HOST_NAME_MAX = 180 SC_IOV_MAX = 60 SC_IPV6 = 235 SC_JOB_CONTROL = 7 SC_LINE_MAX = 43 SC_LOGIN_NAME_MAX = 71 SC_MAPPED_FILES = 16 SC_MEMLOCK = 17 SC_MEMLOCK_RANGE = 18 SC_MEMORY_PROTECTION = 19 SC_MESSAGE_PASSING = 20 SC_MONOTONIC_CLOCK = 149 SC_MQ_OPEN_MAX = 27 SC_MQ_PRIO_MAX = 28 SC_NGROUPS_MAX = 3 SC_NPROCESSORS_CONF = 83 SC_NPROCESSORS_ONLN = 84 SC_OPEN_MAX = 4 SC_PAGESIZE = 30 SC_PAGE_SIZE = 30 SC_PASS_MAX = 88 SC_PRIORITIZED_IO = 13 SC_PRIORITY_SCHEDULING = 10 SC_RAW_SOCKETS = 236 SC_READER_WRITER_LOCKS = 153 SC_REALTIME_SIGNALS = 9 SC_REGEXP = 155 SC_RE_DUP_MAX = 44 SC_RTSIG_MAX = 31 SC_SAVED_IDS = 8 SC_SEMAPHORES = 21 SC_SEM_NSEMS_MAX = 32 SC_SEM_VALUE_MAX = 33 SC_SHARED_MEMORY_OBJECTS = 22 SC_SHELL = 157 SC_SIGQUEUE_MAX = 34 SC_SPAWN = 159 SC_SPIN_LOCKS = 154 SC_SPORADIC_SERVER = 160 # _SC_SS_REPL_MAX not available SC_STREAM_MAX = 5 SC_SYMLOOP_MAX = 173 SC_SYNCHRONIZED_IO = 14 SC_THREADS = 67 SC_THREAD_ATTR_STACKADDR = 77 SC_THREAD_ATTR_STACKSIZE = 78 SC_THREAD_CPUTIME = 139 SC_THREAD_DESTRUCTOR_ITERATIONS = 73 SC_THREAD_KEYS_MAX = 74 SC_THREAD_PRIORITY_SCHEDULING = 79 SC_THREAD_PRIO_INHERIT = 80 SC_THREAD_PRIO_PROTECT = 81 SC_THREAD_PROCESS_SHARED = 82 SC_THREAD_SAFE_FUNCTIONS = 68 SC_THREAD_SPORADIC_SERVER = 161 SC_THREAD_STACK_MIN = 75 SC_THREAD_THREADS_MAX = 76 SC_TIMEOUTS = 164 SC_TIMERS = 11 SC_TIMER_MAX = 35 SC_TRACE = 181 SC_TRACE_EVENT_FILTER = 182 # _SC_TRACE_EVENT_NAME_MAX not available SC_TRACE_INHERIT = 183 SC_TRACE_LOG = 184 # _SC_TRACE_NAME_MAX not available # _SC_TRACE_SYS_MAX not available # _SC_TRACE_USER_EVENT_MAX not available SC_TTY_NAME_MAX = 72 SC_TYPED_MEMORY_OBJECTS = 165 SC_TZNAME_MAX = 6 SC_V6_ILP32_OFF32 = 176 SC_V6_ILP32_OFFBIG = 177 SC_V6_LP64_OFF64 = 178 SC_V6_LPBIG_OFFBIG = 179 SC_VERSION = 29 SC_XBS5_ILP32_OFF32 = 125 SC_XBS5_ILP32_OFFBIG = 126 SC_XBS5_LP64_OFF64 = 127 SC_XBS5_LPBIG_OFFBIG = 128 SC_XOPEN_CRYPT = 92 SC_XOPEN_ENH_I18N = 93 SC_XOPEN_LEGACY = 129 SC_XOPEN_REALTIME = 130 SC_XOPEN_REALTIME_THREADS = 131 SC_XOPEN_SHM = 94 # _SC_XOPEN_STREAMS not available SC_XOPEN_UNIX = 91 SC_XOPEN_VERSION = 89 SC_XOPEN_XCU_VERSION = 90 end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-linux/errno.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-linux/errno.rb
# This file is generated by rake. Do not edit. module Platform; end module Platform::Errno E2BIG = 7 EACCES = 13 EADDRINUSE = 98 EADDRNOTAVAIL = 99 EAFNOSUPPORT = 97 EAGAIN = 11 EALREADY = 114 EBADF = 9 EBUSY = 16 ECHILD = 10 ECONNABORTED = 103 ECONNREFUSED = 111 ECONNRESET = 104 EDEADLK = 35 EDESTADDRREQ = 89 EEXIST = 17 EFAULT = 14 EFBIG = 27 EHOSTDOWN = 112 EHOSTUNREACH = 113 EINPROGRESS = 115 EINTR = 4 EINVAL = 22 EIO = 5 EISCONN = 106 EISDIR = 21 ELOOP = 40 EMFILE = 24 EMLINK = 31 EMSGSIZE = 90 ENAMETOOLONG = 36 ENETDOWN = 100 ENETRESET = 102 ENETUNREACH = 101 ENFILE = 23 ENOBUFS = 105 ENODEV = 19 ENOENT = 2 ENOEXEC = 8 ENOMEM = 12 ENOPROTOOPT = 92 ENOSPC = 28 ENOTCONN = 107 ENOTDIR = 20 ENOTEMPTY = 39 ENOTSOCK = 88 ENOTTY = 25 ENXIO = 6 EOPNOTSUPP = 95 EPERM = 1 EPIPE = 32 EPROTONOSUPPORT = 93 EPROTOTYPE = 91 EROFS = 30 ESPIPE = 29 ESRCH = 3 ETIMEDOUT = 110 ETXTBSY = 26 EWOULDBLOCK = 11 EXDEV = 18 end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-linux/socket.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-linux/socket.rb
# This file is generated by rake. Do not edit. module Platform; end module Platform::Socket AF_APPLETALK = 5 # AF_ATM not available AF_AX25 = 3 # AF_CCITT not available # AF_CHAOS not available # AF_CNT not available # AF_COIP not available # AF_DATAKIT not available AF_DECnet = 12 # AF_DLI not available # AF_E164 not available # AF_ECMA not available # AF_HYLINK not available # AF_IMPLINK not available AF_INET = 2 AF_INET6 = 10 AF_IPX = 4 AF_ISDN = 34 # AF_ISO not available # AF_LAT not available # AF_LINK not available AF_LOCAL = 1 AF_MAX = 35 # AF_NATM not available # AF_NDRV not available # AF_NETBIOS not available # AF_NETGRAPH not available # AF_NS not available # AF_OSI not available # AF_PPP not available # AF_PUP not available AF_ROUTE = 16 # AF_SIP not available AF_SNA = 22 # AF_SYSTEM not available AF_UNIX = 1 AF_UNSPEC = 0 NI_DGRAM = 16 # NI_FQDN_FLAG_VALIDTTL not available NI_MAXHOST = 1025 NI_MAXSERV = 32 NI_NAMEREQD = 8 # NI_NODEADDR_FLAG_ALL not available # NI_NODEADDR_FLAG_ANYCAST not available # NI_NODEADDR_FLAG_COMPAT not available # NI_NODEADDR_FLAG_GLOBAL not available # NI_NODEADDR_FLAG_LINKLOCAL not available # NI_NODEADDR_FLAG_SITELOCAL not available # NI_NODEADDR_FLAG_TRUNCATE not available NI_NOFQDN = 4 NI_NUMERICHOST = 1 NI_NUMERICSERV = 2 # NI_QTYPE_DNSNAME not available # NI_QTYPE_FQDN not available # NI_QTYPE_IPV4ADDR not available # NI_QTYPE_NODEADDR not available # NI_QTYPE_NOOP not available # NI_QTYPE_SUPTYPES not available # NI_SUPTYPE_FLAG_COMPRESS not available # NI_WITHSCOPEID not available PF_APPLETALK = 5 # PF_ATM not available # PF_CCITT not available # PF_CHAOS not available # PF_CNT not available # PF_COIP not available # PF_DATAKIT not available PF_DECnet = 12 # PF_DLI not available # PF_ECMA not available # PF_HYLINK not available # PF_IMPLINK not available PF_INET = 2 PF_INET6 = 10 PF_IPX = 4 PF_ISDN = 34 # PF_ISO not available PF_KEY = 15 # PF_LAT not available # PF_LINK not available PF_LOCAL = 1 PF_MAX = 35 # PF_NATM not available # PF_NDRV not available # PF_NETBIOS not available # PF_NETGRAPH not available # PF_NS not available # PF_OSI not available # PF_PIP not available # PF_PPP not available # PF_PUP not available PF_ROUTE = 16 # PF_RTIP not available # PF_SIP not available PF_SNA = 22 # PF_SYSTEM not available PF_UNIX = 1 PF_UNSPEC = 0 # PF_XTP not available SOCK_DGRAM = 2 # SOCK_MAXADDRLEN not available SOCK_RAW = 3 SOCK_RDM = 4 SOCK_SEQPACKET = 5 SOCK_STREAM = 1 SO_ACCEPTCONN = 30 # SO_ACCEPTFILTER not available SO_ATTACH_FILTER = 26 SO_BINDTODEVICE = 25 SO_BROADCAST = 6 SO_DEBUG = 1 SO_DETACH_FILTER = 27 SO_DONTROUTE = 5 # SO_DONTTRUNC not available SO_ERROR = 4 SO_KEEPALIVE = 9 # SO_LABEL not available SO_LINGER = 13 # SO_NKE not available # SO_NOADDRERR not available # SO_NOSIGPIPE not available SO_NO_CHECK = 11 # SO_NREAD not available # SO_NWRITE not available SO_OOBINLINE = 10 SO_PASSCRED = 16 SO_PEERCRED = 17 # SO_PEERLABEL not available SO_PEERNAME = 28 SO_PRIORITY = 12 SO_RCVBUF = 8 SO_RCVLOWAT = 18 SO_RCVTIMEO = 20 SO_REUSEADDR = 2 # SO_REUSEPORT not available # SO_REUSESHAREUID not available SO_SECURITY_AUTHENTICATION = 22 SO_SECURITY_ENCRYPTION_NETWORK = 24 SO_SECURITY_ENCRYPTION_TRANSPORT = 23 SO_SNDBUF = 7 SO_SNDLOWAT = 19 SO_SNDTIMEO = 21 SO_TIMESTAMP = 29 SO_TYPE = 3 # SO_USELOOPBACK not available # SO_WANTMORE not available # SO_WANTOOBFLAG not available # pseudo_AF_HDRCMPLT not available # pseudo_AF_KEY not available # pseudo_AF_PIP not available # pseudo_AF_RTIP not available # pseudo_AF_XTP not available end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-linux/stat.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-linux/stat.rb
# This file is generated by rake. Do not edit. module Platform module Stat class Stat < FFI::Struct self.size = 144 layout :st_dev, :dev_t, 0, :st_ino, :ino_t, 8, :st_nlink, :nlink_t, 16, :st_mode, :mode_t, 24, :st_uid, :uid_t, 28, :st_gid, :gid_t, 32, :st_size, :off_t, 48, :st_blocks, :blkcnt_t, 64, :st_atime, :time_t, 72, :st_mtime, :time_t, 88, :st_ctime, :time_t, 104 end module Constants S_IEXEC = 0x40 S_IREAD = 0x100 S_IRGRP = 0x20 S_IROTH = 0x4 S_IRUSR = 0x100 S_IRWXG = 0x38 S_IRWXO = 0x7 S_IRWXU = 0x1c0 S_ISGID = 0x400 S_ISUID = 0x800 S_IWGRP = 0x10 S_IWOTH = 0x2 S_IWRITE = 0x80 S_IWUSR = 0x80 S_IXGRP = 0x8 S_IXOTH = 0x1 S_IXUSR = 0x40 end include Constants end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-linux/etc.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-linux/etc.rb
# This file is generated by rake. Do not edit. module Platform; end module Platform::Etc class Passwd < FFI::Struct self.size = 48 layout :pw_name, :string, 0, :pw_passwd, :string, 8, :pw_uid, :uint, 16, :pw_gid, :uint, 20, :pw_dir, :string, 32, :pw_shell, :string, 40 end class Group < FFI::Struct self.size = 32 layout :gr_name, :string, 0, :gr_gid, :uint, 16 end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-linux/syslog.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-linux/syslog.rb
# This file is generated by rake. Do not edit. module Syslog module Constants LOG_ALERT = 1 LOG_AUTH = 32 LOG_AUTHPRIV = 80 LOG_CONS = 2 # LOG_CONSOLE not available LOG_CRIT = 2 LOG_CRON = 72 LOG_DAEMON = 24 LOG_DEBUG = 7 LOG_EMERG = 0 LOG_ERR = 3 LOG_FTP = 88 LOG_INFO = 6 LOG_KERN = 0 LOG_LOCAL0 = 128 LOG_LOCAL1 = 136 LOG_LOCAL2 = 144 LOG_LOCAL3 = 152 LOG_LOCAL4 = 160 LOG_LOCAL5 = 168 LOG_LOCAL6 = 176 LOG_LOCAL7 = 184 LOG_LPR = 48 LOG_MAIL = 16 LOG_NEWS = 56 # LOG_NODELAY not available LOG_NOTICE = 5 LOG_NOWAIT = 16 # LOG_NTP not available LOG_ODELAY = 4 LOG_PERROR = 32 LOG_PID = 1 # LOG_SECURITY not available LOG_SYSLOG = 40 LOG_USER = 8 LOG_UUCP = 64 LOG_WARNING = 4 end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-linux/fcntl.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-linux/fcntl.rb
# This file is generated by rake. Do not edit. module Fcntl FD_CLOEXEC = 1 F_DUPFD = 0 F_GETFD = 1 F_GETFL = 3 F_GETLK = 5 F_RDLCK = 0 F_SETFD = 2 F_SETFL = 4 F_SETLK = 6 F_SETLKW = 7 F_UNLCK = 2 F_WRLCK = 1 O_ACCMODE = 3 O_APPEND = 1024 O_CREAT = 64 O_EXCL = 128 O_NDELAY = 2048 O_NOCTTY = 256 O_NONBLOCK = 2048 O_RDONLY = 0 O_RDWR = 2 O_TRUNC = 512 O_WRONLY = 1 end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-linux/zlib.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-linux/zlib.rb
# This file is generated by rake. Do not edit. ## # The Zlib module contains several classes for compressing and decompressing # streams, and for working with "gzip" files. # # == Classes # # Following are the classes that are most likely to be of interest to the # user: # - Zlib::Inflate # - Zlib::Deflate # - Zlib::GzipReader # - Zlib::GzipWriter # # There are two important base classes for the classes above: Zlib::ZStream # and Zlib::GzipFile. Everything else is an error class. # # == Constants # # Here's a list. # # Zlib::VERSION # The Ruby/zlib version string. # # Zlib::ZLIB_VERSION # The string which represents the version of zlib.h. # # Zlib::BINARY # Zlib::ASCII # Zlib::UNKNOWN # The integers representing data types which Zlib::ZStream#data_type # method returns. # # Zlib::NO_COMPRESSION # Zlib::BEST_SPEED # Zlib::BEST_COMPRESSION # Zlib::DEFAULT_COMPRESSION # The integers representing compression levels which are an argument # for Zlib::Deflate.new, Zlib::Deflate#deflate, and so on. # # Zlib::FILTERED # Zlib::HUFFMAN_ONLY # Zlib::DEFAULT_STRATEGY # The integers representing compression methods which are an argument # for Zlib::Deflate.new and Zlib::Deflate#params. # # Zlib::DEF_MEM_LEVEL # Zlib::MAX_MEM_LEVEL # The integers representing memory levels which are an argument for # Zlib::Deflate.new, Zlib::Deflate#params, and so on. # # Zlib::MAX_WBITS # The default value of windowBits which is an argument for # Zlib::Deflate.new and Zlib::Inflate.new. # # Zlib::NO_FLUSH # Zlib::SYNC_FLUSH # Zlib::FULL_FLUSH # Zlib::FINISH # The integers to control the output of the deflate stream, which are # an argument for Zlib::Deflate#deflate and so on. #-- # These constants are missing! # # Zlib::OS_CODE # Zlib::OS_MSDOS # Zlib::OS_AMIGA # Zlib::OS_VMS # Zlib::OS_UNIX # Zlib::OS_VMCMS # Zlib::OS_ATARI # Zlib::OS_OS2 # Zlib::OS_MACOS # Zlib::OS_ZSYSTEM # Zlib::OS_CPM # Zlib::OS_TOPS20 # Zlib::OS_WIN32 # Zlib::OS_QDOS # Zlib::OS_RISCOS # Zlib::OS_UNKNOWN # The return values of Zlib::GzipFile#os_code method. module Zlib ZLIB_VERSION = "1.2.3" BEST_COMPRESSION = 9 BEST_SPEED = 1 BLOCK = 5 BUF_ERROR = -5 DATA_ERROR = -3 DEFAULT_COMPRESSION = -1 DEFAULT_STRATEGY = 0 DEFLATED = 8 ERRNO = -1 FILTERED = 1 FINISH = 4 FIXED = 4 FULL_FLUSH = 3 HUFFMAN_ONLY = 2 MEM_ERROR = -4 NEED_DICT = 2 NO_COMPRESSION = 0 NO_FLUSH = 0 OK = 0 PARTIAL_FLUSH = 1 RLE = 3 STREAM_END = 1 STREAM_ERROR = -2 SYNC_FLUSH = 2 VERSION_ERROR = -6 # DEF_MEM_LEVEL not available MAX_MEM_LEVEL = 9 MAX_WBITS = 15 OS_MSDOS = 0x00 OS_AMIGA = 0x01 OS_VMS = 0x02 OS_UNIX = 0x03 OS_ATARI = 0x05 OS_OS2 = 0x06 OS_MACOS = 0x07 OS_TOPS20 = 0x0a OS_WIN32 = 0x0b OS_VMCMS = 0x04 OS_ZSYSTEM = 0x08 OS_CPM = 0x09 OS_QDOS = 0x0c OS_RISCOS = 0x0d OS_UNKNOWN = 0xff # OS_CODE not available unless defined? OS_CODE then OS_CODE = OS_UNIX end # from zutil.h unless defined? DEF_MEM_LEVEL then DEF_MEM_LEVEL = MAX_MEM_LEVEL >= 8 ? 8 : MAX_MEM_LEVEL end class Error < StandardError; end class StreamEnd < Error; end class NeedDict < Error; end class StreamError < Error; end class DataError < Error; end class BufError < Error; end class VersionError < Error; end class MemError < Error; end ## # Zlib::ZStream is the abstract class for the stream which handles the # compressed data. The operations are defined in the subclasses: # Zlib::Deflate for compression, and Zlib::Inflate for decompression. # # An instance of Zlib::ZStream has one stream (struct zstream in the source) # and two variable-length buffers which associated to the input (next_in) of # the stream and the output (next_out) of the stream. In this document, # "input buffer" means the buffer for input, and "output buffer" means the # buffer for output. # # Data input into an instance of Zlib::ZStream are temporally stored into # the end of input buffer, and then data in input buffer are processed from # the beginning of the buffer until no more output from the stream is # produced (i.e. until avail_out > 0 after processing). During processing, # output buffer is allocated and expanded automatically to hold all output # data. # # Some particular instance methods consume the data in output buffer and # return them as a String. # # Here is an ascii art for describing above: # # +================ an instance of Zlib::ZStream ================+ # || || # || +--------+ +-------+ +--------+ || # || +--| output |<---------|zstream|<---------| input |<--+ || # || | | buffer | next_out+-------+next_in | buffer | | || # || | +--------+ +--------+ | || # || | | || # +===|======================================================|===+ # | | # v | # "output data" "input data" # # If an error occurs during processing input buffer, an exception which is a # subclass of Zlib::Error is raised. At that time, both input and output # buffer keep their conditions at the time when the error occurs. # # == Method Catalogue # # Many of the methods in this class are fairly low-level and unlikely to be # of interest to users. In fact, users are unlikely to use this class # directly; rather they will be interested in Zlib::Inflate and # Zlib::Deflate. # # The higher level methods are listed below. # # - #total_in # - #total_out # - #data_type # - #adler # - #reset # - #finish # - #finished? # - #close # - #closed? class ZStream < FFI::Struct self.size = 112 layout :next_in, :pointer, 0, :avail_in, :uint, 8, :total_in, :ulong, 16, :next_out, :pointer, 24, :avail_out, :uint, 32, :total_out, :ulong, 40, :msg, :string, 48, :state, :pointer, 56, :zalloc, :pointer, 64, :zfree, :pointer, 72, :opaque, :pointer, 80, :data_type, :int, 88, :adler, :ulong, 96, :reserved, :ulong, 104 #-- # HACK from MRI's zlib.c #++ READY = 0x1 IN_STREAM = 0x2 FINISHED = 0x4 CLOSING = 0x8 UNUSED = 0x10 attr_accessor :flags attr_reader :input attr_reader :output def self.inherited(subclass) subclass.instance_variable_set :@layout, @layout subclass.instance_variable_set :@size, @size end def initialize super self[:avail_in] = 0 self[:avail_out] = 0 self[:next_in] = nil self[:opaque] = nil self[:zalloc] = nil self[:zfree] = nil reset_input @output = nil @flags = 0 @func = nil end def closing? @flags & CLOSING == CLOSING end def detatch_output if @output.nil? then data = '' else data = @output @output = nil self[:avail_out] = 0 self[:next_out] = nil end data end ## # Closes the stream. All operations on the closed stream will raise an # exception. def end unless ready? then warn "attempt to close uninitialized stream; ignored." return nil end if in_stream? then warn "attempt to close unfinished zstream; reset forced" reset end reset_input err = Zlib.send @func_end, pointer Zlib.handle_error err, message @flags = 0 # HACK this may be wrong @output = nil @next_out.free unless @next_out.nil? @next_out = nil nil end alias :close :end def expand_output if @output.nil? then @output = '' @next_out = MemoryPointer.new CHUNK if @next_out.nil? @next_out.write_string "\000" * CHUNK self[:next_out] = @next_out else have = CHUNK - self[:avail_out] @output << @next_out.read_string(have) self[:next_out] = @next_out # Zlib advances self[:next_out] end self[:avail_out] = CHUNK end ## # Finishes the stream and flushes output buffer. See Zlib::Deflate#finish # and Zlib::Inflate#finish for details of this behavior. def finish run '', Zlib::FINISH detatch_output end ## # Returns true if the stream is finished. def finished? @flags & FINISHED == FINISHED end ## # Flushes output buffer and returns all data in that buffer. def flush_next_out detatch_output end def in_stream? @flags & IN_STREAM == IN_STREAM end def input_empty? @input.nil? or @input.empty? end ## # The msg field of the struct def message self[:msg] end def ready @flags |= READY end def ready? @flags & READY == READY end ## # Resets and initializes the stream. All data in both input and output # buffer are discarded. def reset err = Zlib.send @func_reset, pointer Zlib.handle_error err, message @flags = READY reset_input end def reset_input @input = nil end def run(data, flush) if @input.nil? and data.empty? then data_in = MemoryPointer.new 1 data_in.write_string "\000", 1 self[:next_in] = data_in self[:avail_in] = 0 else @input ||= '' @input << data data_in = MemoryPointer.new @input.length data_in.write_string @input, @input.length self[:next_in] = data_in self[:avail_in] = @input.length end expand_output if self[:avail_out] == 0 loop do err = Zlib.send @func_run, pointer, flush available = self[:avail_out] expand_output # HACK does this work when err is set? if err == Zlib::STREAM_END then @flags &= ~IN_STREAM @flags |= FINISHED break end unless err == Zlib::OK then if flush != Zlib::FINISH and err == Zlib::BUF_ERROR and self[:avail_out] > 0 then @flags |= IN_STREAM break end if self[:avail_in] > 0 then @input = self[:next_in].read_string(self[:avail_in]) + @input end Zlib.handle_error err, message end if available > 0 then @flags |= IN_STREAM break end end reset_input if self[:avail_in] > 0 then @input = self[:next_in].read_string self[:avail_in] end ensure data_in.free self[:next_in] = nil end ## # Returns the number of bytes consumed def total_in self[:total_in] end ## # Returns the number bytes processed def total_out self[:total_out] end end set_ffi_lib 'libz' # deflateInit2 is a macro pointing to deflateInit2_ attach_function :deflateInit2_, [ :pointer, # z_streamp strm :int, # int level :int, # int method :int, # int windowBits :int, # int memLevel :int, # int strategy :string, # ZLIB_VERSION :int # (int)sizeof(z_stream) ], :int def self.deflateInit2(stream, level, method, window_bits, mem_level, strategy) deflateInit2_ stream, level, method, window_bits, mem_level, strategy, ZLIB_VERSION, ZStream.size end attach_function :deflate, [:pointer, :int], :int attach_function :deflateEnd, [:pointer], :int attach_function :deflateParams, [:pointer, :int, :int], :int attach_function :deflateReset, [:pointer], :int attach_function :deflateSetDictionary, [:pointer, :string, :uint], :int # inflateInit2 is a macro pointing to inflateInit2_ attach_function :inflateInit2_, [:pointer, :int, :string, :int], :int def self.inflateInit2(stream, window_bits) inflateInit2_ stream, window_bits, ZLIB_VERSION, ZStream.size end attach_function :inflate, [:pointer, :int], :int attach_function :inflateEnd, [:pointer], :int attach_function :inflateReset, [:pointer], :int attach_function :inflateSetDictionary, [:pointer, :string, :uint], :int attach_function :adler32_c, :adler32, [:ulong, :string, :uint], :ulong attach_function :crc32_c, :crc32, [:ulong, :string, :uint], :ulong attach_function :get_crc_table_c, :get_crc_table, [], :pointer attach_function :zError, [:int], :string # Chunk size for inflation and deflation CHUNK = 1024 #-- # HACK from zlib.c #++ GZ_EXTRAFLAG_FAST = 0x4 GZ_EXTRAFLAG_SLOW = 0x2 ## # Zlib::Deflate is the class for compressing data. See Zlib::ZStream for # more information. class Deflate < ZStream ## # Compresses the given +string+. Valid values of level are # <tt>Zlib::NO_COMPRESSION</tt>, <tt>Zlib::BEST_SPEED</tt>, # <tt>Zlib::BEST_COMPRESSION</tt>, <tt>Zlib::DEFAULT_COMPRESSION</tt>, and # an integer from 0 to 9. # # This method is almost equivalent to the following code: # # def deflate(string, level) # z = Zlib::Deflate.new(level) # dst = z.deflate(string, Zlib::FINISH) # z.close # dst # end def self.deflate(data, level = Zlib::DEFAULT_COMPRESSION) deflator = new level zipped = deflator.deflate data, Zlib::FINISH zipped ensure deflator.end end ## # Creates a new deflate stream for compression. See zlib.h for details of # each argument. If an argument is nil, the default value of that argument # is used. def initialize(level = Zlib::DEFAULT_COMPRESSION, window_bits = Zlib::MAX_WBITS, mem_level = Zlib::DEF_MEM_LEVEL, strategy = Zlib::DEFAULT_STRATEGY) level ||= Zlib::DEFAULT_COMPRESSION window_bits ||= Zlib::MAX_WBITS mem_level ||= Zlib::DEF_MEM_LEVEL strategy ||= Zlib::DEFAULT_STRATEGY super() @func_end = :deflateEnd @func_reset = :deflateReset @func_run = :deflate err = Zlib.deflateInit2(pointer, level, Zlib::DEFLATED, window_bits, mem_level, strategy) Zlib.handle_error err, message ready end ## # Same as IO. def <<(data) do_deflate data, Zlib::NO_FLUSH self end ## # Inputs +string+ into the deflate stream and returns the output from the # stream. On calling this method, both the input and the output buffers # of the stream are flushed. If +string+ is nil, this method finishes the # stream, just like Zlib::ZStream#finish. # # The value of +flush+ should be either <tt>Zlib::NO_FLUSH</tt>, # <tt>Zlib::SYNC_FLUSH</tt>, <tt>Zlib::FULL_FLUSH</tt>, or # <tt>Zlib::FINISH</tt>. See zlib.h for details. def deflate(data, flush = Zlib::NO_FLUSH) do_deflate data, flush detatch_output end ## # Performs the deflate operation and leaves the compressed data in the # output buffer def do_deflate(data, flush) if data.nil? then run '', Zlib::FINISH else data = StringValue data if flush != Zlib::NO_FLUSH or not data.empty? then # prevent BUF_ERROR run data, flush end end end ## # Finishes compressing the deflate input stream and returns the output # buffer. def finish run '', Zlib::FINISH detatch_output end ## # This method is equivalent to <tt>deflate('', flush)</tt>. If flush is # omitted, <tt>Zlib::SYNC_FLUSH</tt> is used as flush. This method is # just provided to improve the readability of your Ruby program. def flush(flush = Zlib::SYNC_FLUSH) run '', flush unless flush == Zlib::NO_FLUSH detatch_output end ## # Changes the parameters of the deflate stream. See zlib.h for details. # The output from the stream by changing the params is preserved in output # buffer. def params(level, strategy) err = Zlib.deflateParams pointer, level, strategy raise Zlib::BufError, 'buffer expansion not implemented' if err == Zlib::BUF_ERROR Zlib.handle_error err, message nil end ## # Sets the preset dictionary and returns +dictionary+. This method is # available just only after Zlib::Deflate.new or Zlib::ZStream#reset # method was called. See zlib.h for details. def set_dictionary(dictionary) dict = StringValue dictionary err = Zlib.deflateSetDictionary pointer, dict, dict.length Zlib.handle_error err, message dictionary end end ## # Zlib::GzipFile is an abstract class for handling a gzip formatted # compressed file. The operations are defined in the subclasses, # Zlib::GzipReader for reading, and Zlib::GzipWriter for writing. # # GzipReader should be used by associating an IO, or IO-like, object. class GzipFile SYNC = Zlib::ZStream::UNUSED HEADER_FINISHED = Zlib::ZStream::UNUSED << 1 FOOTER_FINISHED = Zlib::ZStream::UNUSED << 2 FLAG_MULTIPART = 0x2 FLAG_EXTRA = 0x4 FLAG_ORIG_NAME = 0x8 FLAG_COMMENT = 0x10 FLAG_ENCRYPT = 0x20 FLAG_UNKNOWN_MASK = 0xc0 EXTRAFLAG_FAST = 0x4 EXTRAFLAG_SLOW = 0x2 MAGIC1 = 0x1f MAGIC2 = 0x8b METHOD_DEFLATE = 8 ## # Base class of errors that occur when processing GZIP files. class Error < Zlib::Error; end ## # Raised when gzip file footer is not found. class NoFooter < Error; end ## # Raised when the CRC checksum recorded in gzip file footer is not # equivalent to the CRC checksum of the actual uncompressed data. class CRCError < Error; end ## # Raised when the data length recorded in the gzip file footer is not # equivalent to the length of the actual uncompressed data. class LengthError < Error; end ## # Accessor for the underlying ZStream attr_reader :zstream # :nodoc: ## # See Zlib::GzipReader#wrap and Zlib::GzipWriter#wrap. def self.wrap(*args) obj = new(*args) if block_given? then begin yield obj ensure obj.close if obj.zstream.ready? end end end def initialize @comment = nil @crc = 0 @level = nil @mtime = Time.at 0 @orig_name = nil @os_code = Zlib::OS_CODE end ## # Closes the GzipFile object. This method calls close method of the # associated IO object. Returns the associated IO object. def close io = finish io.close if io.respond_to? :close io end ## # Same as IO def closed? @io.nil? end ## # Returns comments recorded in the gzip file header, or nil if the # comment is not present. def comment raise Error, 'closed gzip stream' if @io.nil? @comment.dup end def end return if @zstream.closing? @zstream.flags |= Zlib::ZStream::CLOSING begin end_run ensure @zstream.end end end ## # Closes the GzipFile object. Unlike Zlib::GzipFile#close, this method # never calls the close method of the associated IO object. Returns the # associated IO object. def finish self.end io = @io @io = nil @orig_name = nil @comment = nil io end def finished? @zstream.finished? and @zstream.output.empty? # HACK I think end def footer_finished? @zstream.flags & Zlib::GzipFile::FOOTER_FINISHED == Zlib::GzipFile::FOOTER_FINISHED end def header_finished? @zstream.flags & Zlib::GzipFile::HEADER_FINISHED == Zlib::GzipFile::HEADER_FINISHED end ## # Returns last modification time recorded in the gzip file header. def mtime Time.at @mtime end ## # Returns original filename recorded in the gzip file header, or +nil+ if # original filename is not present. def orig_name raise Error, 'closed gzip stream' if @io.nil? @orig_name.dup end end ## # Zlib::GzipReader is the class for reading a gzipped file. GzipReader # should be used an IO, or -IO-lie, object. # # Zlib::GzipReader.open('hoge.gz') {|gz| # print gz.read # } # # File.open('hoge.gz') do |f| # gz = Zlib::GzipReader.new(f) # print gz.read # gz.close # end # # == Method Catalogue # # The following methods in Zlib::GzipReader are just like their counterparts # in IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an # error was found in the gzip file. # # - #each # - #each_line # - #each_byte # - #gets # - #getc # - #lineno # - #lineno= # - #read # - #readchar # - #readline # - #readlines # - #ungetc # # Be careful of the footer of the gzip file. A gzip file has the checksum of # pre-compressed data in its footer. GzipReader checks all uncompressed data # against that checksum at the following cases, and if it fails, raises # <tt>Zlib::GzipFile::NoFooter</tt>, <tt>Zlib::GzipFile::CRCError</tt>, or # <tt>Zlib::GzipFile::LengthError</tt> exception. # # - When an reading request is received beyond the end of file (the end of # compressed data). That is, when Zlib::GzipReader#read, # Zlib::GzipReader#gets, or some other methods for reading returns nil. # - When Zlib::GzipFile#close method is called after the object reaches the # end of file. # - When Zlib::GzipReader#unused method is called after the object reaches # the end of file. # # The rest of the methods are adequately described in their own # documentation. class GzipReader < GzipFile # HACK use a buffer class ## # Creates a GzipReader object associated with +io+. The GzipReader object # reads gzipped data from +io+, and parses/decompresses them. At least, # +io+ must have a +read+ method that behaves same as the +read+ method in # IO class. # # If the gzip file header is incorrect, raises an Zlib::GzipFile::Error # exception. def initialize(io) @io = io @zstream = Zlib::Inflate.new -Zlib::MAX_WBITS @buffer = '' super() read_header end def check_footer @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED footer = @zstream.input.slice! 0, 8 rest = @io.read 8 - footer.length footer << rest if rest raise NoFooter, 'footer is not found' unless footer.length == 8 crc, length = footer.unpack 'VV' @zstream[:total_in] += 8 # to rewind correctly raise CRCError, 'invalid compressed data -- crc error' unless @crc == crc raise LengthError, 'invalid compressed data -- length error' unless length == @zstream.total_out end def end_run check_footer if @zstream.finished? and not footer_finished? end def eof? @zstream.finished? and @zstream.input_empty? end def pos @zstream[:total_out] - @buffer.length end ## # See Zlib::GzipReader documentation for a description. def read(length = nil) data = @buffer while chunk = @io.read(CHUNK) do inflated = @zstream.inflate(chunk) @crc = Zlib.crc32 inflated, @crc data << inflated break if length and data.length > length end if length then @buffer = data.slice! length..-1 else @buffer = '' end check_footer if @zstream.finished? and not footer_finished? data rescue Zlib::Error => e raise GzipFile::Error, e.message end def read_header header = @io.read 10 raise Error, 'not in gzip format' unless header.length == 10 magic1, magic2, method, flags, @mtime, extra_flags, @os_code = header.unpack 'CCCCVCC' unless magic1 == Zlib::GzipFile::MAGIC1 and magic2 == Zlib::GzipFile::MAGIC2 then raise Error, 'not in gzip format' end unless method == Zlib::GzipFile::METHOD_DEFLATE then raise Error, "unsupported compression method #{method}" end if flags & Zlib::GzipFile::FLAG_MULTIPART == Zlib::GzipFile::FLAG_MULTIPART then raise Error, 'multi-part gzip file is not supported' end if flags & Zlib::GzipFile::FLAG_ENCRYPT == Zlib::GzipFile::FLAG_ENCRYPT then raise Error, 'encrypted gzip file is not supported' end if flags & Zlib::GzipFile::FLAG_UNKNOWN_MASK == Zlib::GzipFile::FLAG_UNKNOWN_MASK then raise Error, "unknown flags 0x#{flags.to_s 16}" end if extra_flags & Zlib::GzipFile::EXTRAFLAG_FAST == Zlib::GzipFile::EXTRAFLAG_FAST then @level = Zlib::BEST_SPEED elsif extra_flags & Zlib::GzipFile::EXTRAFLAG_SLOW == Zlib::GzipFile::EXTRAFLAG_SLOW then @level = Zlib::BEST_COMPRESSION else @level = Zlib::DEFAULT_COMPRESSION end if flags & Zlib::GzipFile::FLAG_EXTRA == Zlib::GzipFile::FLAG_EXTRA then length = @io.read 2 raise Zlib::GzipFile::Error, 'unexpected end of file' if length.nil? or length.length != 2 length, = length.unpack 'v' extra = @io.read length + 2 raise Zlib::GzipFile::Error, 'unexpected end of file' if extra.nil? or extra.length != length + 2 end if flags & Zlib::GzipFile::FLAG_ORIG_NAME == Zlib::GzipFile::FLAG_ORIG_NAME then @orig_name = '' c = @io.getc until c == 0 do @orig_name << c.chr c = @io.getc end end if flags & Zlib::GzipFile::FLAG_COMMENT == Zlib::GzipFile::FLAG_COMMENT then @comment = '' c = @io.getc until c == 0 do @comment << c.chr c = @io.getc end end end end ## # Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should # be used with an instance of IO, or IO-like, object. # # For example: # # Zlib::GzipWriter.open('hoge.gz') do |gz| # gz.write 'jugemu jugemu gokou no surikire...' # end # # File.open('hoge.gz', 'w') do |f| # gz = Zlib::GzipWriter.new(f) # gz.write 'jugemu jugemu gokou no surikire...' # gz.close # end # # NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close # GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter # will be not able to write the gzip footer and will generate a broken gzip # file. class GzipWriter < GzipFile # HACK use a buffer class ## # Set the comment attr_writer :comment ## # Set the original name attr_writer :orig_name ## # Creates a GzipWriter object associated with +io+. +level+ and +strategy+ # should be the same as the arguments of Zlib::Deflate.new. The # GzipWriter object writes gzipped data to +io+. At least, +io+ must # respond to the +write+ method that behaves same as write method in IO # class. def initialize(io, level = Zlib::DEFAULT_COMPRESSION, strategy = Zlib::DEFAULT_STRATEGY) @io = io @zstream = Zlib::Deflate.new level, -Zlib::MAX_WBITS, Zlib::DEF_MEM_LEVEL, strategy @buffer = '' super() end def end_run make_header unless header_finished? @zstream.run '', Zlib::FINISH write_raw make_footer nil end ## # Flushes all the internal buffers of the GzipWriter object. The meaning # of +flush+ is same as in Zlib::Deflate#deflate. # <tt>Zlib::SYNC_FLUSH</tt> is used if +flush+ is omitted. It is no use # giving flush <tt>Zlib::NO_FLUSH</tt>. def flush true end ## # Writes out a gzip header def make_header flags = 0 extra_flags = 0 flags |= Zlib::GzipFile::FLAG_ORIG_NAME if @orig_name flags |= Zlib::GzipFile::FLAG_COMMENT if @comment extra_flags |= Zlib::GzipFile::EXTRAFLAG_FAST if @level == Zlib::BEST_SPEED extra_flags |= Zlib::GzipFile::EXTRAFLAG_SLOW if @level == Zlib::BEST_COMPRESSION header = [ Zlib::GzipFile::MAGIC1, # byte 0 Zlib::GzipFile::MAGIC2, # byte 1 Zlib::GzipFile::METHOD_DEFLATE, # byte 2 flags, # byte 3 @mtime.to_i, # bytes 4-7 extra_flags, # byte 8 @os_code # byte 9 ].pack 'CCCCVCC' @io.write header @io.write "#{@orig_name}\0" if @orig_name @io.write "#{@comment}\0" if @comment @zstream.flags |= Zlib::GzipFile::HEADER_FINISHED end ## # Writes out a gzip footer def make_footer footer = [ @crc, # bytes 0-3 @zstream.total_in, # bytes 4-7 ].pack 'VV' @io.write footer @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED end ## # Sets the modification time of this file def mtime=(time) if header_finished? then raise Zlib::GzipFile::Error, 'header is already written' end @mtime = Integer time end def sync? @zstream.flags & Zlib::GzipFile::SYNC == Zlib::GzipFile::SYNC end ## # Same as IO. def write(data) make_header unless header_finished? data = String data if data.length > 0 or sync? then @crc = Zlib.crc32_c @crc, data, data.length flush = sync? ? Zlib::SYNC_FLUSH : Zlib::NO_FLUSH @zstream.run data, flush end write_raw end ## # Same as IO. alias << write def write_raw data = @zstream.detatch_output unless data.empty? then @io.write data @io.flush if sync? and io.respond_to :flush end end end ## # Zlib:Inflate is the class for decompressing compressed data. Unlike # Zlib::Deflate, an instance of this class is not able to duplicate (clone, # dup) itself. class Inflate < ZStream ## # Decompresses +string+. Raises a Zlib::NeedDict exception if a preset # dictionary is needed for decompression. # # This method is almost equivalent to the following code: # # def inflate(string) # zstream = Zlib::Inflate.new # buf = zstream.inflate(string) # zstream.finish # zstream.close # buf # end def self.inflate(data) inflator = new unzipped = inflator.inflate data unzipped ensure inflator.end end ## # Creates a new inflate stream for decompression. See zlib.h for details # of the argument. If +window_bits+ is +nil+, the default value is used. def initialize(window_bits = Zlib::MAX_WBITS) super() @func_end = :inflateEnd @func_reset = :inflateReset @func_run = :inflate err = Zlib.inflateInit2 pointer, window_bits Zlib.handle_error err, message # HACK ready end ## # Inputs +string+ into the inflate stream just like Zlib::Inflate#inflate, # but returns the Zlib::Inflate object itself. The output from the stream # is preserved in output buffer. def <<(string) string = StringValue string unless string.nil? if finished? then unless string.nil? then @input ||= '' @input << string end else run string, Zlib::SYNC_FLUSH end end ## # Inputs +string+ into the inflate stream and returns the output from the # stream. Calling this method, both the input and the output buffer of # the stream are flushed. If string is +nil+, this method finishes the
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
true
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-linux/sysconf.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/x86_64-linux/sysconf.rb
# This file is generated by rake. Do not edit. module Platform;end module Platform::Sysconf SC_2_CHAR_TERM = 95 SC_2_C_BIND = 47 SC_2_C_DEV = 48 SC_2_FORT_DEV = 49 SC_2_FORT_RUN = 50 SC_2_LOCALEDEF = 52 SC_2_PBS = 168 SC_2_PBS_ACCOUNTING = 169 SC_2_PBS_CHECKPOINT = 175 SC_2_PBS_LOCATE = 170 SC_2_PBS_MESSAGE = 171 SC_2_PBS_TRACK = 172 SC_2_SW_DEV = 51 SC_2_UPE = 97 SC_2_VERSION = 46 SC_ADVISORY_INFO = 132 SC_AIO_LISTIO_MAX = 23 SC_AIO_MAX = 24 SC_AIO_PRIO_DELTA_MAX = 25 SC_ARG_MAX = 0 SC_ASYNCHRONOUS_IO = 12 SC_ATEXIT_MAX = 87 SC_BARRIERS = 133 SC_BC_BASE_MAX = 36 SC_BC_DIM_MAX = 37 SC_BC_SCALE_MAX = 38 SC_BC_STRING_MAX = 39 SC_CHILD_MAX = 1 SC_CLK_TCK = 2 SC_CLOCK_SELECTION = 137 SC_COLL_WEIGHTS_MAX = 40 SC_CPUTIME = 138 SC_DELAYTIMER_MAX = 26 SC_EXPR_NEST_MAX = 42 SC_FILE_LOCKING = 147 SC_FSYNC = 15 SC_GETGR_R_SIZE_MAX = 69 SC_GETPW_R_SIZE_MAX = 70 SC_HOST_NAME_MAX = 180 SC_IOV_MAX = 60 SC_IPV6 = 235 SC_JOB_CONTROL = 7 SC_LINE_MAX = 43 SC_LOGIN_NAME_MAX = 71 SC_MAPPED_FILES = 16 SC_MEMLOCK = 17 SC_MEMLOCK_RANGE = 18 SC_MEMORY_PROTECTION = 19 SC_MESSAGE_PASSING = 20 SC_MONOTONIC_CLOCK = 149 SC_MQ_OPEN_MAX = 27 SC_MQ_PRIO_MAX = 28 SC_NGROUPS_MAX = 3 SC_NPROCESSORS_CONF = 83 SC_NPROCESSORS_ONLN = 84 SC_OPEN_MAX = 4 SC_PAGESIZE = 30 SC_PAGE_SIZE = 30 SC_PASS_MAX = 88 SC_PRIORITIZED_IO = 13 SC_PRIORITY_SCHEDULING = 10 SC_RAW_SOCKETS = 236 SC_READER_WRITER_LOCKS = 153 SC_REALTIME_SIGNALS = 9 SC_REGEXP = 155 SC_RE_DUP_MAX = 44 SC_RTSIG_MAX = 31 SC_SAVED_IDS = 8 SC_SEMAPHORES = 21 SC_SEM_NSEMS_MAX = 32 SC_SEM_VALUE_MAX = 33 SC_SHARED_MEMORY_OBJECTS = 22 SC_SHELL = 157 SC_SIGQUEUE_MAX = 34 SC_SPAWN = 159 SC_SPIN_LOCKS = 154 SC_SPORADIC_SERVER = 160 # _SC_SS_REPL_MAX not available SC_STREAM_MAX = 5 SC_SYMLOOP_MAX = 173 SC_SYNCHRONIZED_IO = 14 SC_THREADS = 67 SC_THREAD_ATTR_STACKADDR = 77 SC_THREAD_ATTR_STACKSIZE = 78 SC_THREAD_CPUTIME = 139 SC_THREAD_DESTRUCTOR_ITERATIONS = 73 SC_THREAD_KEYS_MAX = 74 SC_THREAD_PRIORITY_SCHEDULING = 79 SC_THREAD_PRIO_INHERIT = 80 SC_THREAD_PRIO_PROTECT = 81 SC_THREAD_PROCESS_SHARED = 82 SC_THREAD_SAFE_FUNCTIONS = 68 SC_THREAD_SPORADIC_SERVER = 161 SC_THREAD_STACK_MIN = 75 SC_THREAD_THREADS_MAX = 76 SC_TIMEOUTS = 164 SC_TIMERS = 11 SC_TIMER_MAX = 35 SC_TRACE = 181 SC_TRACE_EVENT_FILTER = 182 # _SC_TRACE_EVENT_NAME_MAX not available SC_TRACE_INHERIT = 183 SC_TRACE_LOG = 184 # _SC_TRACE_NAME_MAX not available # _SC_TRACE_SYS_MAX not available # _SC_TRACE_USER_EVENT_MAX not available SC_TTY_NAME_MAX = 72 SC_TYPED_MEMORY_OBJECTS = 165 SC_TZNAME_MAX = 6 SC_V6_ILP32_OFF32 = 176 SC_V6_ILP32_OFFBIG = 177 SC_V6_LP64_OFF64 = 178 SC_V6_LPBIG_OFFBIG = 179 SC_VERSION = 29 SC_XBS5_ILP32_OFF32 = 125 SC_XBS5_ILP32_OFFBIG = 126 SC_XBS5_LP64_OFF64 = 127 SC_XBS5_LPBIG_OFFBIG = 128 SC_XOPEN_CRYPT = 92 SC_XOPEN_ENH_I18N = 93 SC_XOPEN_LEGACY = 129 SC_XOPEN_REALTIME = 130 SC_XOPEN_REALTIME_THREADS = 131 SC_XOPEN_SHM = 94 # _SC_XOPEN_STREAMS not available SC_XOPEN_UNIX = 91 SC_XOPEN_VERSION = 89 SC_XOPEN_XCU_VERSION = 90 end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-windows/errno.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-windows/errno.rb
# This file is generated by rake. Do not edit. module Platform; end module Platform::Errno E2BIG = 7 EACCES = 13 EADDRINUSE = 112 EADDRNOTAVAIL = 125 EAFNOSUPPORT = 106 EAGAIN = 11 EALREADY = 120 EBADF = 9 EBUSY = 16 ECHILD = 10 ECONNABORTED = 113 ECONNREFUSED = 111 ECONNRESET = 104 EDEADLK = 45 EDESTADDRREQ = 121 EEXIST = 17 EFAULT = 14 EFBIG = 27 EHOSTDOWN = 117 EHOSTUNREACH = 118 EINPROGRESS = 119 EINTR = 4 EINVAL = 22 EIO = 5 EISCONN = 127 EISDIR = 21 ELOOP = 92 EMFILE = 24 EMLINK = 31 EMSGSIZE = 122 ENAMETOOLONG = 91 ENETDOWN = 115 ENETRESET = 126 ENETUNREACH = 114 ENFILE = 23 ENOBUFS = 105 ENODEV = 19 ENOENT = 2 ENOEXEC = 8 ENOMEM = 12 ENOPROTOOPT = 109 ENOSPC = 28 ENOTCONN = 128 ENOTDIR = 20 ENOTEMPTY = 90 ENOTSOCK = 108 ENOTTY = 25 ENXIO = 6 EOPNOTSUPP = 95 EPERM = 1 EPIPE = 32 EPROTONOSUPPORT = 123 EPROTOTYPE = 107 EROFS = 30 ESPIPE = 29 ESRCH = 3 ETIMEDOUT = 116 ETXTBSY = 26 EWOULDBLOCK = 11 EXDEV = 18 end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-windows/etc.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-windows/etc.rb
# This file is generated by rake. Do not edit. module Platform; end module Platform::Etc class Passwd < FFI::Struct layout :pw_name, :string, 0, :pw_passwd, :string, 4, :pw_uid, :uint, 8, :pw_gid, :uint, 12, :pw_dir, :string, 24, :pw_shell, :string, 28 end class Group < FFI::Struct layout :gr_name, :string, 0, :gr_gid, :uint, 8 end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-windows/fcntl.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-windows/fcntl.rb
# This file is generated by rake. Do not edit. module Fcntl FD_CLOEXEC = 1 F_DUPFD = 0 F_GETFD = 1 F_GETFL = 3 F_GETLK = 7 F_RDLCK = 1 F_SETFD = 2 F_SETFL = 4 F_SETLK = 8 F_SETLKW = 9 F_UNLCK = 3 F_WRLCK = 2 O_ACCMODE = 3 O_APPEND = 8 O_CREAT = 512 O_EXCL = 2048 O_NDELAY = 16384 O_NOCTTY = 32768 O_NONBLOCK = 16384 O_RDONLY = 0 O_RDWR = 2 O_TRUNC = 1024 O_WRONLY = 1 end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-windows/zlib.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-windows/zlib.rb
# This file is generated by rake. Do not edit. ## # The Zlib module contains several classes for compressing and decompressing # streams, and for working with "gzip" files. # # == Classes # # Following are the classes that are most likely to be of interest to the # user: # - Zlib::Inflate # - Zlib::Deflate # - Zlib::GzipReader # - Zlib::GzipWriter # # There are two important base classes for the classes above: Zlib::ZStream # and Zlib::GzipFile. Everything else is an error class. # # == Constants # # Here's a list. # # Zlib::VERSION # The Ruby/zlib version string. # # Zlib::ZLIB_VERSION # The string which represents the version of zlib.h. # # Zlib::BINARY # Zlib::ASCII # Zlib::UNKNOWN # The integers representing data types which Zlib::ZStream#data_type # method returns. # # Zlib::NO_COMPRESSION # Zlib::BEST_SPEED # Zlib::BEST_COMPRESSION # Zlib::DEFAULT_COMPRESSION # The integers representing compression levels which are an argument # for Zlib::Deflate.new, Zlib::Deflate#deflate, and so on. # # Zlib::FILTERED # Zlib::HUFFMAN_ONLY # Zlib::DEFAULT_STRATEGY # The integers representing compression methods which are an argument # for Zlib::Deflate.new and Zlib::Deflate#params. # # Zlib::DEF_MEM_LEVEL # Zlib::MAX_MEM_LEVEL # The integers representing memory levels which are an argument for # Zlib::Deflate.new, Zlib::Deflate#params, and so on. # # Zlib::MAX_WBITS # The default value of windowBits which is an argument for # Zlib::Deflate.new and Zlib::Inflate.new. # # Zlib::NO_FLUSH # Zlib::SYNC_FLUSH # Zlib::FULL_FLUSH # Zlib::FINISH # The integers to control the output of the deflate stream, which are # an argument for Zlib::Deflate#deflate and so on. #-- # These constants are missing! # # Zlib::OS_CODE # Zlib::OS_MSDOS # Zlib::OS_AMIGA # Zlib::OS_VMS # Zlib::OS_UNIX # Zlib::OS_VMCMS # Zlib::OS_ATARI # Zlib::OS_OS2 # Zlib::OS_MACOS # Zlib::OS_ZSYSTEM # Zlib::OS_CPM # Zlib::OS_TOPS20 # Zlib::OS_WIN32 # Zlib::OS_QDOS # Zlib::OS_RISCOS # Zlib::OS_UNKNOWN # The return values of Zlib::GzipFile#os_code method. module Zlib ZLIB_VERSION = "1.2.3" BEST_COMPRESSION = 9 BEST_SPEED = 1 BLOCK = 5 BUF_ERROR = -5 DATA_ERROR = -3 DEFAULT_COMPRESSION = -1 DEFAULT_STRATEGY = 0 DEFLATED = 8 ERRNO = -1 FILTERED = 1 FINISH = 4 FIXED = 4 FULL_FLUSH = 3 HUFFMAN_ONLY = 2 MEM_ERROR = -4 NEED_DICT = 2 NO_COMPRESSION = 0 NO_FLUSH = 0 OK = 0 PARTIAL_FLUSH = 1 RLE = 3 STREAM_END = 1 STREAM_ERROR = -2 SYNC_FLUSH = 2 VERSION_ERROR = -6 # DEF_MEM_LEVEL not available MAX_MEM_LEVEL = 9 MAX_WBITS = 15 OS_MSDOS = 0x00 OS_AMIGA = 0x01 OS_VMS = 0x02 OS_UNIX = 0x03 OS_ATARI = 0x05 OS_OS2 = 0x06 OS_MACOS = 0x07 OS_TOPS20 = 0x0a OS_WIN32 = 0x0b OS_VMCMS = 0x04 OS_ZSYSTEM = 0x08 OS_CPM = 0x09 OS_QDOS = 0x0c OS_RISCOS = 0x0d OS_UNKNOWN = 0xff # OS_CODE not available unless defined? OS_CODE then OS_CODE = OS_UNIX end # from zutil.h unless defined? DEF_MEM_LEVEL then DEF_MEM_LEVEL = MAX_MEM_LEVEL >= 8 ? 8 : MAX_MEM_LEVEL end class Error < StandardError; end class StreamEnd < Error; end class NeedDict < Error; end class StreamError < Error; end class DataError < Error; end class BufError < Error; end class VersionError < Error; end class MemError < Error; end ## # Zlib::ZStream is the abstract class for the stream which handles the # compressed data. The operations are defined in the subclasses: # Zlib::Deflate for compression, and Zlib::Inflate for decompression. # # An instance of Zlib::ZStream has one stream (struct zstream in the source) # and two variable-length buffers which associated to the input (next_in) of # the stream and the output (next_out) of the stream. In this document, # "input buffer" means the buffer for input, and "output buffer" means the # buffer for output. # # Data input into an instance of Zlib::ZStream are temporally stored into # the end of input buffer, and then data in input buffer are processed from # the beginning of the buffer until no more output from the stream is # produced (i.e. until avail_out > 0 after processing). During processing, # output buffer is allocated and expanded automatically to hold all output # data. # # Some particular instance methods consume the data in output buffer and # return them as a String. # # Here is an ascii art for describing above: # # +================ an instance of Zlib::ZStream ================+ # || || # || +--------+ +-------+ +--------+ || # || +--| output |<---------|zstream|<---------| input |<--+ || # || | | buffer | next_out+-------+next_in | buffer | | || # || | +--------+ +--------+ | || # || | | || # +===|======================================================|===+ # | | # v | # "output data" "input data" # # If an error occurs during processing input buffer, an exception which is a # subclass of Zlib::Error is raised. At that time, both input and output # buffer keep their conditions at the time when the error occurs. # # == Method Catalogue # # Many of the methods in this class are fairly low-level and unlikely to be # of interest to users. In fact, users are unlikely to use this class # directly; rather they will be interested in Zlib::Inflate and # Zlib::Deflate. # # The higher level methods are listed below. # # - #total_in # - #total_out # - #data_type # - #adler # - #reset # - #finish # - #finished? # - #close # - #closed? class ZStream < FFI::Struct layout :next_in, :pointer, 0, :avail_in, :uint, 4, :total_in, :ulong, 8, :next_out, :pointer, 12, :avail_out, :uint, 16, :total_out, :ulong, 20, :msg, :string, 24, :state, :pointer, 28, :zalloc, :pointer, 32, :zfree, :pointer, 36, :opaque, :pointer, 40, :data_type, :int, 44, :adler, :ulong, 48, :reserved, :ulong, 52 #-- # HACK from MRI's zlib.c #++ READY = 0x1 IN_STREAM = 0x2 FINISHED = 0x4 CLOSING = 0x8 UNUSED = 0x10 attr_accessor :flags attr_reader :input attr_reader :output def self.inherited(subclass) subclass.instance_variable_set :@layout, @layout subclass.instance_variable_set :@size, @size end def initialize super self[:avail_in] = 0 self[:avail_out] = 0 self[:next_in] = nil self[:opaque] = nil self[:zalloc] = nil self[:zfree] = nil reset_input @output = nil @flags = 0 @func = nil end def closing? @flags & CLOSING == CLOSING end def detatch_output if @output.nil? then data = '' else data = @output @output = nil self[:avail_out] = 0 self[:next_out] = nil end data end ## # Closes the stream. All operations on the closed stream will raise an # exception. def end unless ready? then warn "attempt to close uninitialized stream; ignored." return nil end if in_stream? then warn "attempt to close unfinished zstream; reset forced" reset end reset_input err = Zlib.send @func_end, pointer Zlib.handle_error err, message @flags = 0 # HACK this may be wrong @output = nil @next_out.free unless @next_out.nil? @next_out = nil nil end alias :close :end def expand_output if @output.nil? then @output = '' @next_out = MemoryPointer.new CHUNK if @next_out.nil? @next_out.write_string "\000" * CHUNK self[:next_out] = @next_out else have = CHUNK - self[:avail_out] @output << @next_out.read_string(have) self[:next_out] = @next_out # Zlib advances self[:next_out] end self[:avail_out] = CHUNK end ## # Finishes the stream and flushes output buffer. See Zlib::Deflate#finish # and Zlib::Inflate#finish for details of this behavior. def finish run '', Zlib::FINISH detatch_output end ## # Returns true if the stream is finished. def finished? @flags & FINISHED == FINISHED end ## # Flushes output buffer and returns all data in that buffer. def flush_next_out detatch_output end def in_stream? @flags & IN_STREAM == IN_STREAM end def input_empty? @input.nil? or @input.empty? end ## # The msg field of the struct def message self[:msg] end def ready @flags |= READY end def ready? @flags & READY == READY end ## # Resets and initializes the stream. All data in both input and output # buffer are discarded. def reset err = Zlib.send @func_reset, pointer Zlib.handle_error err, message @flags = READY reset_input end def reset_input @input = nil end def run(data, flush) if @input.nil? and data.empty? then data_in = MemoryPointer.new 1 data_in.write_string "\000", 1 self[:next_in] = data_in self[:avail_in] = 0 else @input ||= '' @input << data data_in = MemoryPointer.new @input.length data_in.write_string @input, @input.length self[:next_in] = data_in self[:avail_in] = @input.length end expand_output if self[:avail_out] == 0 loop do err = Zlib.send @func_run, pointer, flush available = self[:avail_out] expand_output # HACK does this work when err is set? if err == Zlib::STREAM_END then @flags &= ~IN_STREAM @flags |= FINISHED break end unless err == Zlib::OK then if flush != Zlib::FINISH and err == Zlib::BUF_ERROR and self[:avail_out] > 0 then @flags |= IN_STREAM break end if self[:avail_in] > 0 then @input = self[:next_in].read_string(self[:avail_in]) + @input end Zlib.handle_error err, message end if available > 0 then @flags |= IN_STREAM break end end reset_input if self[:avail_in] > 0 then @input = self[:next_in].read_string self[:avail_in] end ensure data_in.free self[:next_in] = nil end ## # Returns the number of bytes consumed def total_in self[:total_in] end ## # Returns the number bytes processed def total_out self[:total_out] end end set_ffi_lib 'libz' # deflateInit2 is a macro pointing to deflateInit2_ attach_function 'deflateInit2_', :deflateInit2_, [ :pointer, # z_streamp strm :int, # int level :int, # int method :int, # int windowBits :int, # int memLevel :int, # int strategy :string, # ZLIB_VERSION :int # (int)sizeof(z_stream) ], :int def self.deflateInit2(stream, level, method, window_bits, mem_level, strategy) deflateInit2_ stream, level, method, window_bits, mem_level, strategy, ZLIB_VERSION, ZStream.size end attach_function 'deflate', :deflate, [:pointer, :int], :int attach_function 'deflateEnd', :deflateEnd, [:pointer], :int attach_function 'deflateParams', :deflateParams, [:pointer, :int, :int], :int attach_function 'deflateReset', :deflateReset, [:pointer], :int attach_function 'deflateSetDictionary', :deflateSetDictionary, [:pointer, :string, :uint], :int # inflateInit2 is a macro pointing to inflateInit2_ attach_function 'inflateInit2_', :inflateInit2_, [:pointer, :int, :string, :int], :int def self.inflateInit2(stream, window_bits) inflateInit2_ stream, window_bits, ZLIB_VERSION, ZStream.size end attach_function 'inflate', :inflate, [:pointer, :int], :int attach_function 'inflateEnd', :inflateEnd, [:pointer], :int attach_function 'inflateReset', :inflateReset, [:pointer], :int attach_function 'inflateSetDictionary', :inflateSetDictionary, [:pointer, :string, :uint], :int attach_function 'adler32', :adler32_c, [:ulong, :string, :uint], :ulong attach_function 'crc32', :crc32_c, [:ulong, :string, :uint], :ulong attach_function 'get_crc_table', :get_crc_table_c, [], :pointer attach_function 'zError', :zError, [:int], :string # Chunk size for inflation and deflation CHUNK = 1024 #-- # HACK from zlib.c #++ GZ_EXTRAFLAG_FAST = 0x4 GZ_EXTRAFLAG_SLOW = 0x2 ## # Zlib::Deflate is the class for compressing data. See Zlib::ZStream for # more information. class Deflate < ZStream ## # Compresses the given +string+. Valid values of level are # <tt>Zlib::NO_COMPRESSION</tt>, <tt>Zlib::BEST_SPEED</tt>, # <tt>Zlib::BEST_COMPRESSION</tt>, <tt>Zlib::DEFAULT_COMPRESSION</tt>, and # an integer from 0 to 9. # # This method is almost equivalent to the following code: # # def deflate(string, level) # z = Zlib::Deflate.new(level) # dst = z.deflate(string, Zlib::FINISH) # z.close # dst # end def self.deflate(data, level = Zlib::DEFAULT_COMPRESSION) deflator = new level zipped = deflator.deflate data, Zlib::FINISH zipped ensure deflator.end end ## # Creates a new deflate stream for compression. See zlib.h for details of # each argument. If an argument is nil, the default value of that argument # is used. def initialize(level = Zlib::DEFAULT_COMPRESSION, window_bits = Zlib::MAX_WBITS, mem_level = Zlib::DEF_MEM_LEVEL, strategy = Zlib::DEFAULT_STRATEGY) level ||= Zlib::DEFAULT_COMPRESSION window_bits ||= Zlib::MAX_WBITS mem_level ||= Zlib::DEF_MEM_LEVEL strategy ||= Zlib::DEFAULT_STRATEGY super() @func_end = :deflateEnd @func_reset = :deflateReset @func_run = :deflate err = Zlib.deflateInit2(pointer, level, Zlib::DEFLATED, window_bits, mem_level, strategy) Zlib.handle_error err, message ready end ## # Same as IO. def <<(data) do_deflate data, Zlib::NO_FLUSH self end ## # Inputs +string+ into the deflate stream and returns the output from the # stream. On calling this method, both the input and the output buffers # of the stream are flushed. If +string+ is nil, this method finishes the # stream, just like Zlib::ZStream#finish. # # The value of +flush+ should be either <tt>Zlib::NO_FLUSH</tt>, # <tt>Zlib::SYNC_FLUSH</tt>, <tt>Zlib::FULL_FLUSH</tt>, or # <tt>Zlib::FINISH</tt>. See zlib.h for details. def deflate(data, flush = Zlib::NO_FLUSH) do_deflate data, flush detatch_output end ## # Performs the deflate operation and leaves the compressed data in the # output buffer def do_deflate(data, flush) if data.nil? then run '', Zlib::FINISH else data = StringValue data if flush != Zlib::NO_FLUSH or not data.empty? then # prevent BUF_ERROR run data, flush end end end ## # Finishes compressing the deflate input stream and returns the output # buffer. def finish run '', Zlib::FINISH detatch_output end ## # This method is equivalent to <tt>deflate('', flush)</tt>. If flush is # omitted, <tt>Zlib::SYNC_FLUSH</tt> is used as flush. This method is # just provided to improve the readability of your Ruby program. def flush(flush = Zlib::SYNC_FLUSH) run '', flush unless flush == Zlib::NO_FLUSH detatch_output end ## # Changes the parameters of the deflate stream. See zlib.h for details. # The output from the stream by changing the params is preserved in output # buffer. def params(level, strategy) err = Zlib.deflateParams pointer, level, strategy raise Zlib::BufError, 'buffer expansion not implemented' if err == Zlib::BUF_ERROR Zlib.handle_error err, message nil end ## # Sets the preset dictionary and returns +dictionary+. This method is # available just only after Zlib::Deflate.new or Zlib::ZStream#reset # method was called. See zlib.h for details. def set_dictionary(dictionary) dict = StringValue dictionary err = Zlib.deflateSetDictionary pointer, dict, dict.length Zlib.handle_error err, message dictionary end end ## # Zlib::GzipFile is an abstract class for handling a gzip formatted # compressed file. The operations are defined in the subclasses, # Zlib::GzipReader for reading, and Zlib::GzipWriter for writing. # # GzipReader should be used by associating an IO, or IO-like, object. class GzipFile SYNC = Zlib::ZStream::UNUSED HEADER_FINISHED = Zlib::ZStream::UNUSED << 1 FOOTER_FINISHED = Zlib::ZStream::UNUSED << 2 FLAG_MULTIPART = 0x2 FLAG_EXTRA = 0x4 FLAG_ORIG_NAME = 0x8 FLAG_COMMENT = 0x10 FLAG_ENCRYPT = 0x20 FLAG_UNKNOWN_MASK = 0xc0 EXTRAFLAG_FAST = 0x4 EXTRAFLAG_SLOW = 0x2 MAGIC1 = 0x1f MAGIC2 = 0x8b METHOD_DEFLATE = 8 ## # Base class of errors that occur when processing GZIP files. class Error < Zlib::Error; end ## # Raised when gzip file footer is not found. class NoFooter < Error; end ## # Raised when the CRC checksum recorded in gzip file footer is not # equivalent to the CRC checksum of the actual uncompressed data. class CRCError < Error; end ## # Raised when the data length recorded in the gzip file footer is not # equivalent to the length of the actual uncompressed data. class LengthError < Error; end ## # Accessor for the underlying ZStream attr_reader :zstream # :nodoc: ## # See Zlib::GzipReader#wrap and Zlib::GzipWriter#wrap. def self.wrap(*args) obj = new(*args) if block_given? then begin yield obj ensure obj.close if obj.zstream.ready? end end end def initialize @comment = nil @crc = 0 @level = nil @mtime = Time.at 0 @orig_name = nil @os_code = Zlib::OS_CODE end ## # Closes the GzipFile object. This method calls close method of the # associated IO object. Returns the associated IO object. def close io = finish io.close if io.respond_to? :close io end ## # Same as IO def closed? @io.nil? end ## # Returns comments recorded in the gzip file header, or nil if the # comment is not present. def comment raise Error, 'closed gzip stream' if @io.nil? @comment.dup end def end return if @zstream.closing? @zstream.flags |= Zlib::ZStream::CLOSING begin end_run ensure @zstream.end end end ## # Closes the GzipFile object. Unlike Zlib::GzipFile#close, this method # never calls the close method of the associated IO object. Returns the # associated IO object. def finish self.end io = @io @io = nil @orig_name = nil @comment = nil io end def finished? @zstream.finished? and @zstream.output.empty? # HACK I think end def footer_finished? @zstream.flags & Zlib::GzipFile::FOOTER_FINISHED == Zlib::GzipFile::FOOTER_FINISHED end def header_finished? @zstream.flags & Zlib::GzipFile::HEADER_FINISHED == Zlib::GzipFile::HEADER_FINISHED end ## # Returns last modification time recorded in the gzip file header. def mtime Time.at @mtime end ## # Returns original filename recorded in the gzip file header, or +nil+ if # original filename is not present. def orig_name raise Error, 'closed gzip stream' if @io.nil? @orig_name.dup end end ## # Zlib::GzipReader is the class for reading a gzipped file. GzipReader # should be used an IO, or -IO-lie, object. # # Zlib::GzipReader.open('hoge.gz') {|gz| # print gz.read # } # # File.open('hoge.gz') do |f| # gz = Zlib::GzipReader.new(f) # print gz.read # gz.close # end # # == Method Catalogue # # The following methods in Zlib::GzipReader are just like their counterparts # in IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an # error was found in the gzip file. # # - #each # - #each_line # - #each_byte # - #gets # - #getc # - #lineno # - #lineno= # - #read # - #readchar # - #readline # - #readlines # - #ungetc # # Be careful of the footer of the gzip file. A gzip file has the checksum of # pre-compressed data in its footer. GzipReader checks all uncompressed data # against that checksum at the following cases, and if it fails, raises # <tt>Zlib::GzipFile::NoFooter</tt>, <tt>Zlib::GzipFile::CRCError</tt>, or # <tt>Zlib::GzipFile::LengthError</tt> exception. # # - When an reading request is received beyond the end of file (the end of # compressed data). That is, when Zlib::GzipReader#read, # Zlib::GzipReader#gets, or some other methods for reading returns nil. # - When Zlib::GzipFile#close method is called after the object reaches the # end of file. # - When Zlib::GzipReader#unused method is called after the object reaches # the end of file. # # The rest of the methods are adequately described in their own # documentation. class GzipReader < GzipFile # HACK use a buffer class ## # Creates a GzipReader object associated with +io+. The GzipReader object # reads gzipped data from +io+, and parses/decompresses them. At least, # +io+ must have a +read+ method that behaves same as the +read+ method in # IO class. # # If the gzip file header is incorrect, raises an Zlib::GzipFile::Error # exception. def initialize(io) @io = io @zstream = Zlib::Inflate.new -Zlib::MAX_WBITS @buffer = '' super() read_header end def check_footer @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED footer = @zstream.input.slice! 0, 8 rest = @io.read 8 - footer.length footer << rest if rest raise NoFooter, 'footer is not found' unless footer.length == 8 crc, length = footer.unpack 'VV' @zstream[:total_in] += 8 # to rewind correctly raise CRCError, 'invalid compressed data -- crc error' unless @crc == crc raise LengthError, 'invalid compressed data -- length error' unless length == @zstream.total_out end def end_run check_footer if @zstream.finished? and not footer_finished? end def eof? @zstream.finished? and @zstream.input_empty? end def pos @zstream[:total_out] - @buffer.length end ## # See Zlib::GzipReader documentation for a description. def read(length = nil) data = @buffer while chunk = @io.read(CHUNK) do inflated = @zstream.inflate(chunk) @crc = Zlib.crc32 inflated, @crc data << inflated break if length and data.length > length end if length then @buffer = data.slice! length..-1 else @buffer = '' end check_footer if @zstream.finished? and not footer_finished? data rescue Zlib::Error => e raise GzipFile::Error, e.message end def read_header header = @io.read 10 raise Error, 'not in gzip format' unless header.length == 10 magic1, magic2, method, flags, @mtime, extra_flags, @os_code = header.unpack 'CCCCVCC' unless magic1 == Zlib::GzipFile::MAGIC1 and magic2 == Zlib::GzipFile::MAGIC2 then raise Error, 'not in gzip format' end unless method == Zlib::GzipFile::METHOD_DEFLATE then raise Error, "unsupported compression method #{method}" end if flags & Zlib::GzipFile::FLAG_MULTIPART == Zlib::GzipFile::FLAG_MULTIPART then raise Error, 'multi-part gzip file is not supported' end if flags & Zlib::GzipFile::FLAG_ENCRYPT == Zlib::GzipFile::FLAG_ENCRYPT then raise Error, 'encrypted gzip file is not supported' end if flags & Zlib::GzipFile::FLAG_UNKNOWN_MASK == Zlib::GzipFile::FLAG_UNKNOWN_MASK then raise Error, "unknown flags 0x#{flags.to_s 16}" end if extra_flags & Zlib::GzipFile::EXTRAFLAG_FAST == Zlib::GzipFile::EXTRAFLAG_FAST then @level = Zlib::BEST_SPEED elsif extra_flags & Zlib::GzipFile::EXTRAFLAG_SLOW == Zlib::GzipFile::EXTRAFLAG_SLOW then @level = Zlib::BEST_COMPRESSION else @level = Zlib::DEFAULT_COMPRESSION end if flags & Zlib::GzipFile::FLAG_EXTRA == Zlib::GzipFile::FLAG_EXTRA then length = @io.read 2 raise Zlib::GzipFile::Error, 'unexpected end of file' if length.nil? or length.length != 2 length, = length.unpack 'v' extra = @io.read length + 2 raise Zlib::GzipFile::Error, 'unexpected end of file' if extra.nil? or extra.length != length + 2 end if flags & Zlib::GzipFile::FLAG_ORIG_NAME == Zlib::GzipFile::FLAG_ORIG_NAME then @orig_name = '' c = @io.getc until c == 0 do @orig_name << c.chr c = @io.getc end end if flags & Zlib::GzipFile::FLAG_COMMENT == Zlib::GzipFile::FLAG_COMMENT then @comment = '' c = @io.getc until c == 0 do @comment << c.chr c = @io.getc end end end end ## # Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should # be used with an instance of IO, or IO-like, object. # # For example: # # Zlib::GzipWriter.open('hoge.gz') do |gz| # gz.write 'jugemu jugemu gokou no surikire...' # end # # File.open('hoge.gz', 'w') do |f| # gz = Zlib::GzipWriter.new(f) # gz.write 'jugemu jugemu gokou no surikire...' # gz.close # end # # NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close # GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter # will be not able to write the gzip footer and will generate a broken gzip # file. class GzipWriter < GzipFile # HACK use a buffer class ## # Set the comment attr_writer :comment ## # Set the original name attr_writer :orig_name ## # Creates a GzipWriter object associated with +io+. +level+ and +strategy+ # should be the same as the arguments of Zlib::Deflate.new. The # GzipWriter object writes gzipped data to +io+. At least, +io+ must # respond to the +write+ method that behaves same as write method in IO # class. def initialize(io, level = Zlib::DEFAULT_COMPRESSION, strategy = Zlib::DEFAULT_STRATEGY) @io = io @zstream = Zlib::Deflate.new level, -Zlib::MAX_WBITS, Zlib::DEF_MEM_LEVEL, strategy @buffer = '' super() end def end_run make_header unless header_finished? @zstream.run '', Zlib::FINISH write_raw make_footer nil end ## # Flushes all the internal buffers of the GzipWriter object. The meaning # of +flush+ is same as in Zlib::Deflate#deflate. # <tt>Zlib::SYNC_FLUSH</tt> is used if +flush+ is omitted. It is no use # giving flush <tt>Zlib::NO_FLUSH</tt>. def flush true end ## # Writes out a gzip header def make_header flags = 0 extra_flags = 0 flags |= Zlib::GzipFile::FLAG_ORIG_NAME if @orig_name flags |= Zlib::GzipFile::FLAG_COMMENT if @comment extra_flags |= Zlib::GzipFile::EXTRAFLAG_FAST if @level == Zlib::BEST_SPEED extra_flags |= Zlib::GzipFile::EXTRAFLAG_SLOW if @level == Zlib::BEST_COMPRESSION header = [ Zlib::GzipFile::MAGIC1, # byte 0 Zlib::GzipFile::MAGIC2, # byte 1 Zlib::GzipFile::METHOD_DEFLATE, # byte 2 flags, # byte 3 @mtime.to_i, # bytes 4-7 extra_flags, # byte 8 @os_code # byte 9 ].pack 'CCCCVCC' @io.write header @io.write "#{@orig_name}\0" if @orig_name @io.write "#{@comment}\0" if @comment @zstream.flags |= Zlib::GzipFile::HEADER_FINISHED end ## # Writes out a gzip footer def make_footer footer = [ @crc, # bytes 0-3 @zstream.total_in, # bytes 4-7 ].pack 'VV' @io.write footer @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED end ## # Sets the modification time of this file def mtime=(time) if header_finished? then raise Zlib::GzipFile::Error, 'header is already written' end @mtime = Integer time end def sync? @zstream.flags & Zlib::GzipFile::SYNC == Zlib::GzipFile::SYNC end ## # Same as IO. def write(data) make_header unless header_finished? data = String data if data.length > 0 or sync? then @crc = Zlib.crc32_c @crc, data, data.length flush = sync? ? Zlib::SYNC_FLUSH : Zlib::NO_FLUSH @zstream.run data, flush end write_raw end ## # Same as IO. alias << write def write_raw data = @zstream.detatch_output unless data.empty? then @io.write data @io.flush if sync? and io.respond_to :flush end end end ## # Zlib:Inflate is the class for decompressing compressed data. Unlike # Zlib::Deflate, an instance of this class is not able to duplicate (clone, # dup) itself. class Inflate < ZStream ## # Decompresses +string+. Raises a Zlib::NeedDict exception if a preset # dictionary is needed for decompression. # # This method is almost equivalent to the following code: # # def inflate(string) # zstream = Zlib::Inflate.new # buf = zstream.inflate(string) # zstream.finish # zstream.close # buf # end def self.inflate(data) inflator = new unzipped = inflator.inflate data unzipped ensure inflator.end end ## # Creates a new inflate stream for decompression. See zlib.h for details # of the argument. If +window_bits+ is +nil+, the default value is used. def initialize(window_bits = Zlib::MAX_WBITS) super() @func_end = :inflateEnd @func_reset = :inflateReset @func_run = :inflate err = Zlib.inflateInit2 pointer, window_bits Zlib.handle_error err, message # HACK ready end ## # Inputs +string+ into the inflate stream just like Zlib::Inflate#inflate, # but returns the Zlib::Inflate object itself. The output from the stream # is preserved in output buffer. def <<(string) string = StringValue string unless string.nil? if finished? then unless string.nil? then @input ||= '' @input << string end else run string, Zlib::SYNC_FLUSH end end ##
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
true
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/powerpc-darwin/errno.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/powerpc-darwin/errno.rb
# This file is generated by rake. Do not edit. module Platform; end module Platform::Errno E2BIG = 7 EACCES = 13 EADDRINUSE = 48 EADDRNOTAVAIL = 49 EAFNOSUPPORT = 47 EAGAIN = 35 EALREADY = 37 EBADF = 9 EBUSY = 16 ECHILD = 10 ECONNABORTED = 53 ECONNREFUSED = 61 ECONNRESET = 54 EDEADLK = 11 EDESTADDRREQ = 39 EEXIST = 17 EFAULT = 14 EFBIG = 27 EHOSTDOWN = 64 EHOSTUNREACH = 65 EINPROGRESS = 36 EINTR = 4 EINVAL = 22 EIO = 5 EISCONN = 56 EISDIR = 21 ELOOP = 62 EMFILE = 24 EMLINK = 31 EMSGSIZE = 40 ENAMETOOLONG = 63 ENETDOWN = 50 ENETRESET = 52 ENETUNREACH = 51 ENFILE = 23 ENOBUFS = 55 ENODEV = 19 ENOENT = 2 ENOEXEC = 8 ENOMEM = 12 ENOPROTOOPT = 42 ENOSPC = 28 ENOTCONN = 57 ENOTDIR = 20 ENOTEMPTY = 66 ENOTSOCK = 38 ENOTTY = 25 ENXIO = 6 EOPNOTSUPP = 102 EPERM = 1 EPIPE = 32 EPROTONOSUPPORT = 43 EPROTOTYPE = 41 EROFS = 30 ESPIPE = 29 ESRCH = 3 ETIMEDOUT = 60 ETXTBSY = 26 EWOULDBLOCK = 35 EXDEV = 18 end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/powerpc-darwin/socket.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/powerpc-darwin/socket.rb
# This file is generated by rake. Do not edit. module Platform; end module Platform::Socket AF_APPLETALK = 16 # AF_ATM not available # AF_AX25 not available AF_CCITT = 10 AF_CHAOS = 5 AF_CNT = 21 AF_COIP = 20 AF_DATAKIT = 9 AF_DECnet = 12 AF_DLI = 13 AF_E164 = 28 AF_ECMA = 8 AF_HYLINK = 15 AF_IMPLINK = 3 AF_INET = 2 AF_INET6 = 30 AF_IPX = 23 AF_ISDN = 28 AF_ISO = 7 AF_LAT = 14 AF_LINK = 18 AF_LOCAL = 1 AF_MAX = 37 AF_NATM = 31 AF_NDRV = 27 AF_NETBIOS = 33 # AF_NETGRAPH not available AF_NS = 6 AF_OSI = 7 AF_PPP = 34 AF_PUP = 4 AF_ROUTE = 17 AF_SIP = 24 AF_SNA = 11 AF_SYSTEM = 32 AF_UNIX = 1 AF_UNSPEC = 0 NI_DGRAM = 16 NI_FQDN_FLAG_VALIDTTL = 1 NI_MAXHOST = 1025 NI_MAXSERV = 32 NI_NAMEREQD = 4 NI_NODEADDR_FLAG_ALL = 2 NI_NODEADDR_FLAG_ANYCAST = 64 NI_NODEADDR_FLAG_COMPAT = 4 NI_NODEADDR_FLAG_GLOBAL = 32 NI_NODEADDR_FLAG_LINKLOCAL = 8 NI_NODEADDR_FLAG_SITELOCAL = 16 NI_NODEADDR_FLAG_TRUNCATE = 1 NI_NOFQDN = 1 NI_NUMERICHOST = 2 NI_NUMERICSERV = 8 NI_QTYPE_DNSNAME = 2 NI_QTYPE_FQDN = 2 NI_QTYPE_IPV4ADDR = 4 NI_QTYPE_NODEADDR = 3 NI_QTYPE_NOOP = 0 NI_QTYPE_SUPTYPES = 1 NI_SUPTYPE_FLAG_COMPRESS = 1 NI_WITHSCOPEID = 32 PF_APPLETALK = 16 # PF_ATM not available PF_CCITT = 10 PF_CHAOS = 5 PF_CNT = 21 PF_COIP = 20 PF_DATAKIT = 9 PF_DECnet = 12 PF_DLI = 13 PF_ECMA = 8 PF_HYLINK = 15 PF_IMPLINK = 3 PF_INET = 2 PF_INET6 = 30 PF_IPX = 23 PF_ISDN = 28 PF_ISO = 7 PF_KEY = 29 PF_LAT = 14 PF_LINK = 18 PF_LOCAL = 1 PF_MAX = 37 PF_NATM = 31 PF_NDRV = 27 PF_NETBIOS = 33 # PF_NETGRAPH not available PF_NS = 6 PF_OSI = 7 PF_PIP = 25 PF_PPP = 34 PF_PUP = 4 PF_ROUTE = 17 PF_RTIP = 22 PF_SIP = 24 PF_SNA = 11 PF_SYSTEM = 32 PF_UNIX = 1 PF_UNSPEC = 0 PF_XTP = 19 SOCK_DGRAM = 2 SOCK_MAXADDRLEN = 255 SOCK_RAW = 3 SOCK_RDM = 4 SOCK_SEQPACKET = 5 SOCK_STREAM = 1 SO_ACCEPTCONN = 2 # SO_ACCEPTFILTER not available # SO_ATTACH_FILTER not available # SO_BINDTODEVICE not available SO_BROADCAST = 32 SO_DEBUG = 1 # SO_DETACH_FILTER not available SO_DONTROUTE = 16 SO_DONTTRUNC = 8192 SO_ERROR = 4103 SO_KEEPALIVE = 8 SO_LABEL = 4112 SO_LINGER = 128 SO_NKE = 4129 SO_NOADDRERR = 4131 SO_NOSIGPIPE = 4130 # SO_NO_CHECK not available SO_NREAD = 4128 SO_NWRITE = 4132 SO_OOBINLINE = 256 # SO_PASSCRED not available # SO_PEERCRED not available SO_PEERLABEL = 4113 # SO_PEERNAME not available # SO_PRIORITY not available SO_RCVBUF = 4098 SO_RCVLOWAT = 4100 SO_RCVTIMEO = 4102 SO_REUSEADDR = 4 SO_REUSEPORT = 512 SO_REUSESHAREUID = 4133 # SO_SECURITY_AUTHENTICATION not available # SO_SECURITY_ENCRYPTION_NETWORK not available # SO_SECURITY_ENCRYPTION_TRANSPORT not available SO_SNDBUF = 4097 SO_SNDLOWAT = 4099 SO_SNDTIMEO = 4101 SO_TIMESTAMP = 1024 SO_TYPE = 4104 SO_USELOOPBACK = 64 SO_WANTMORE = 16384 SO_WANTOOBFLAG = 32768 pseudo_AF_HDRCMPLT = 35 pseudo_AF_KEY = 29 pseudo_AF_PIP = 25 pseudo_AF_RTIP = 22 pseudo_AF_XTP = 19 end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/powerpc-darwin/stat.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/powerpc-darwin/stat.rb
# This file is generated by rake. Do not edit. module Platform module Stat class Stat < FFI::Struct self.size = 108 layout :st_dev, :dev_t, 0, :st_ino, :ino_t, 8, :st_nlink, :nlink_t, 6, :st_mode, :mode_t, 4, :st_uid, :uid_t, 16, :st_gid, :gid_t, 20, :st_size, :off_t, 60, :st_blocks, :blkcnt_t, 68, :st_atime, :time_t, 28, :st_mtime, :time_t, 36, :st_ctime, :time_t, 44 end module Constants S_IEXEC = 0x40 S_IREAD = 0x100 S_IRGRP = 0x20 S_IROTH = 0x4 S_IRUSR = 0x100 S_IRWXG = 0x38 S_IRWXO = 0x7 S_IRWXU = 0x1c0 S_ISGID = 0x400 S_ISUID = 0x800 S_IWGRP = 0x10 S_IWOTH = 0x2 S_IWRITE = 0x80 S_IWUSR = 0x80 S_IXGRP = 0x8 S_IXOTH = 0x1 S_IXUSR = 0x40 end include Constants end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/powerpc-darwin/etc.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/powerpc-darwin/etc.rb
# This file is generated by rake. Do not edit. module Platform; end module Platform::Etc class Passwd < FFI::Struct self.size = 40 layout :pw_name, :string, 0, :pw_passwd, :string, 4, :pw_uid, :uint, 8, :pw_gid, :uint, 12, :pw_dir, :string, 28, :pw_shell, :string, 32 end class Group < FFI::Struct self.size = 16 layout :gr_name, :string, 0, :gr_gid, :uint, 8 end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/powerpc-darwin/syslog.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/powerpc-darwin/syslog.rb
# This file is generated by rake. Do not edit. module Syslog module Constants LOG_ALERT = 1 LOG_AUTH = 32 LOG_AUTHPRIV = 80 LOG_CONS = 2 # LOG_CONSOLE not available LOG_CRIT = 2 LOG_CRON = 72 LOG_DAEMON = 24 LOG_DEBUG = 7 LOG_EMERG = 0 LOG_ERR = 3 LOG_FTP = 88 LOG_INFO = 6 LOG_KERN = 0 LOG_LOCAL0 = 128 LOG_LOCAL1 = 136 LOG_LOCAL2 = 144 LOG_LOCAL3 = 152 LOG_LOCAL4 = 160 LOG_LOCAL5 = 168 LOG_LOCAL6 = 176 LOG_LOCAL7 = 184 LOG_LPR = 48 LOG_MAIL = 16 LOG_NEWS = 56 # LOG_NODELAY not available LOG_NOTICE = 5 LOG_NOWAIT = 16 # LOG_NTP not available LOG_ODELAY = 4 LOG_PERROR = 32 LOG_PID = 1 # LOG_SECURITY not available LOG_SYSLOG = 40 LOG_USER = 8 LOG_UUCP = 64 LOG_WARNING = 4 end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/powerpc-darwin/fcntl.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/powerpc-darwin/fcntl.rb
# This file is generated by rake. Do not edit. module Fcntl FD_CLOEXEC = 1 F_DUPFD = 0 F_GETFD = 1 F_GETFL = 3 F_GETLK = 7 F_RDLCK = 1 F_SETFD = 2 F_SETFL = 4 F_SETLK = 8 F_SETLKW = 9 F_UNLCK = 2 F_WRLCK = 3 O_ACCMODE = 3 O_APPEND = 8 O_CREAT = 512 O_EXCL = 2048 O_NDELAY = 4 O_NOCTTY = 131072 O_NONBLOCK = 4 O_RDONLY = 0 O_RDWR = 2 O_TRUNC = 1024 O_WRONLY = 1 end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/powerpc-darwin/zlib.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/powerpc-darwin/zlib.rb
# This file is generated by rake. Do not edit. ## # The Zlib module contains several classes for compressing and decompressing # streams, and for working with "gzip" files. # # == Classes # # Following are the classes that are most likely to be of interest to the # user: # - Zlib::Inflate # - Zlib::Deflate # - Zlib::GzipReader # - Zlib::GzipWriter # # There are two important base classes for the classes above: Zlib::ZStream # and Zlib::GzipFile. Everything else is an error class. # # == Constants # # Here's a list. # # Zlib::VERSION # The Ruby/zlib version string. # # Zlib::ZLIB_VERSION # The string which represents the version of zlib.h. # # Zlib::BINARY # Zlib::ASCII # Zlib::UNKNOWN # The integers representing data types which Zlib::ZStream#data_type # method returns. # # Zlib::NO_COMPRESSION # Zlib::BEST_SPEED # Zlib::BEST_COMPRESSION # Zlib::DEFAULT_COMPRESSION # The integers representing compression levels which are an argument # for Zlib::Deflate.new, Zlib::Deflate#deflate, and so on. # # Zlib::FILTERED # Zlib::HUFFMAN_ONLY # Zlib::DEFAULT_STRATEGY # The integers representing compression methods which are an argument # for Zlib::Deflate.new and Zlib::Deflate#params. # # Zlib::DEF_MEM_LEVEL # Zlib::MAX_MEM_LEVEL # The integers representing memory levels which are an argument for # Zlib::Deflate.new, Zlib::Deflate#params, and so on. # # Zlib::MAX_WBITS # The default value of windowBits which is an argument for # Zlib::Deflate.new and Zlib::Inflate.new. # # Zlib::NO_FLUSH # Zlib::SYNC_FLUSH # Zlib::FULL_FLUSH # Zlib::FINISH # The integers to control the output of the deflate stream, which are # an argument for Zlib::Deflate#deflate and so on. #-- # These constants are missing! # # Zlib::OS_CODE # Zlib::OS_MSDOS # Zlib::OS_AMIGA # Zlib::OS_VMS # Zlib::OS_UNIX # Zlib::OS_VMCMS # Zlib::OS_ATARI # Zlib::OS_OS2 # Zlib::OS_MACOS # Zlib::OS_ZSYSTEM # Zlib::OS_CPM # Zlib::OS_TOPS20 # Zlib::OS_WIN32 # Zlib::OS_QDOS # Zlib::OS_RISCOS # Zlib::OS_UNKNOWN # The return values of Zlib::GzipFile#os_code method. module Zlib ZLIB_VERSION = "1.2.3" BEST_COMPRESSION = 9 BEST_SPEED = 1 BLOCK = 5 BUF_ERROR = -5 DATA_ERROR = -3 DEFAULT_COMPRESSION = -1 DEFAULT_STRATEGY = 0 DEFLATED = 8 ERRNO = -1 FILTERED = 1 FINISH = 4 FIXED = 4 FULL_FLUSH = 3 HUFFMAN_ONLY = 2 MEM_ERROR = -4 NEED_DICT = 2 NO_COMPRESSION = 0 NO_FLUSH = 0 OK = 0 PARTIAL_FLUSH = 1 RLE = 3 STREAM_END = 1 STREAM_ERROR = -2 SYNC_FLUSH = 2 VERSION_ERROR = -6 # DEF_MEM_LEVEL not available MAX_MEM_LEVEL = 9 MAX_WBITS = 15 OS_MSDOS = 0x00 OS_AMIGA = 0x01 OS_VMS = 0x02 OS_UNIX = 0x03 OS_ATARI = 0x05 OS_OS2 = 0x06 OS_MACOS = 0x07 OS_TOPS20 = 0x0a OS_WIN32 = 0x0b OS_VMCMS = 0x04 OS_ZSYSTEM = 0x08 OS_CPM = 0x09 OS_QDOS = 0x0c OS_RISCOS = 0x0d OS_UNKNOWN = 0xff # OS_CODE not available unless defined? OS_CODE then OS_CODE = OS_UNIX end # from zutil.h unless defined? DEF_MEM_LEVEL then DEF_MEM_LEVEL = MAX_MEM_LEVEL >= 8 ? 8 : MAX_MEM_LEVEL end class Error < StandardError; end class StreamEnd < Error; end class NeedDict < Error; end class StreamError < Error; end class DataError < Error; end class BufError < Error; end class VersionError < Error; end class MemError < Error; end ## # Zlib::ZStream is the abstract class for the stream which handles the # compressed data. The operations are defined in the subclasses: # Zlib::Deflate for compression, and Zlib::Inflate for decompression. # # An instance of Zlib::ZStream has one stream (struct zstream in the source) # and two variable-length buffers which associated to the input (next_in) of # the stream and the output (next_out) of the stream. In this document, # "input buffer" means the buffer for input, and "output buffer" means the # buffer for output. # # Data input into an instance of Zlib::ZStream are temporally stored into # the end of input buffer, and then data in input buffer are processed from # the beginning of the buffer until no more output from the stream is # produced (i.e. until avail_out > 0 after processing). During processing, # output buffer is allocated and expanded automatically to hold all output # data. # # Some particular instance methods consume the data in output buffer and # return them as a String. # # Here is an ascii art for describing above: # # +================ an instance of Zlib::ZStream ================+ # || || # || +--------+ +-------+ +--------+ || # || +--| output |<---------|zstream|<---------| input |<--+ || # || | | buffer | next_out+-------+next_in | buffer | | || # || | +--------+ +--------+ | || # || | | || # +===|======================================================|===+ # | | # v | # "output data" "input data" # # If an error occurs during processing input buffer, an exception which is a # subclass of Zlib::Error is raised. At that time, both input and output # buffer keep their conditions at the time when the error occurs. # # == Method Catalogue # # Many of the methods in this class are fairly low-level and unlikely to be # of interest to users. In fact, users are unlikely to use this class # directly; rather they will be interested in Zlib::Inflate and # Zlib::Deflate. # # The higher level methods are listed below. # # - #total_in # - #total_out # - #data_type # - #adler # - #reset # - #finish # - #finished? # - #close # - #closed? class ZStream < FFI::Struct self.size = 56 layout :next_in, :pointer, 0, :avail_in, :uint, 4, :total_in, :ulong, 8, :next_out, :pointer, 12, :avail_out, :uint, 16, :total_out, :ulong, 20, :msg, :string, 24, :state, :pointer, 28, :zalloc, :pointer, 32, :zfree, :pointer, 36, :opaque, :pointer, 40, :data_type, :int, 44, :adler, :ulong, 48, :reserved, :ulong, 52 #-- # HACK from MRI's zlib.c #++ READY = 0x1 IN_STREAM = 0x2 FINISHED = 0x4 CLOSING = 0x8 UNUSED = 0x10 attr_accessor :flags attr_reader :input attr_reader :output def self.inherited(subclass) subclass.instance_variable_set :@layout, @layout subclass.instance_variable_set :@size, @size end def initialize super self[:avail_in] = 0 self[:avail_out] = 0 self[:next_in] = nil self[:opaque] = nil self[:zalloc] = nil self[:zfree] = nil reset_input @output = nil @flags = 0 @func = nil end def closing? @flags & CLOSING == CLOSING end def detatch_output if @output.nil? then data = '' else data = @output @output = nil self[:avail_out] = 0 self[:next_out] = nil end data end ## # Closes the stream. All operations on the closed stream will raise an # exception. def end unless ready? then warn "attempt to close uninitialized stream; ignored." return nil end if in_stream? then warn "attempt to close unfinished zstream; reset forced" reset end reset_input err = Zlib.send @func_end, pointer Zlib.handle_error err, message @flags = 0 # HACK this may be wrong @output = nil @next_out.free unless @next_out.nil? @next_out = nil nil end alias :close :end def expand_output if @output.nil? then @output = '' @next_out = MemoryPointer.new CHUNK if @next_out.nil? @next_out.write_string "\000" * CHUNK self[:next_out] = @next_out else have = CHUNK - self[:avail_out] @output << @next_out.read_string(have) self[:next_out] = @next_out # Zlib advances self[:next_out] end self[:avail_out] = CHUNK end ## # Finishes the stream and flushes output buffer. See Zlib::Deflate#finish # and Zlib::Inflate#finish for details of this behavior. def finish run '', Zlib::FINISH detatch_output end ## # Returns true if the stream is finished. def finished? @flags & FINISHED == FINISHED end ## # Flushes output buffer and returns all data in that buffer. def flush_next_out detatch_output end def in_stream? @flags & IN_STREAM == IN_STREAM end def input_empty? @input.nil? or @input.empty? end ## # The msg field of the struct def message self[:msg] end def ready @flags |= READY end def ready? @flags & READY == READY end ## # Resets and initializes the stream. All data in both input and output # buffer are discarded. def reset err = Zlib.send @func_reset, pointer Zlib.handle_error err, message @flags = READY reset_input end def reset_input @input = nil end def run(data, flush) if @input.nil? and data.empty? then data_in = MemoryPointer.new 1 data_in.write_string "\000", 1 self[:next_in] = data_in self[:avail_in] = 0 else @input ||= '' @input << data data_in = MemoryPointer.new @input.length data_in.write_string @input, @input.length self[:next_in] = data_in self[:avail_in] = @input.length end expand_output if self[:avail_out] == 0 loop do err = Zlib.send @func_run, pointer, flush available = self[:avail_out] expand_output # HACK does this work when err is set? if err == Zlib::STREAM_END then @flags &= ~IN_STREAM @flags |= FINISHED break end unless err == Zlib::OK then if flush != Zlib::FINISH and err == Zlib::BUF_ERROR and self[:avail_out] > 0 then @flags |= IN_STREAM break end if self[:avail_in] > 0 then @input = self[:next_in].read_string(self[:avail_in]) + @input end Zlib.handle_error err, message end if available > 0 then @flags |= IN_STREAM break end end reset_input if self[:avail_in] > 0 then @input = self[:next_in].read_string self[:avail_in] end ensure data_in.free self[:next_in] = nil end ## # Returns the number of bytes consumed def total_in self[:total_in] end ## # Returns the number bytes processed def total_out self[:total_out] end end set_ffi_lib 'libz' # deflateInit2 is a macro pointing to deflateInit2_ attach_function :deflateInit2_, [ :pointer, # z_streamp strm :int, # int level :int, # int method :int, # int windowBits :int, # int memLevel :int, # int strategy :string, # ZLIB_VERSION :int # (int)sizeof(z_stream) ], :int def self.deflateInit2(stream, level, method, window_bits, mem_level, strategy) deflateInit2_ stream, level, method, window_bits, mem_level, strategy, ZLIB_VERSION, ZStream.size end attach_function :deflate, [:pointer, :int], :int attach_function :deflateEnd, [:pointer], :int attach_function :deflateParams, [:pointer, :int, :int], :int attach_function :deflateReset, [:pointer], :int attach_function :deflateSetDictionary, [:pointer, :string, :uint], :int # inflateInit2 is a macro pointing to inflateInit2_ attach_function :inflateInit2_, [:pointer, :int, :string, :int], :int def self.inflateInit2(stream, window_bits) inflateInit2_ stream, window_bits, ZLIB_VERSION, ZStream.size end attach_function :inflate, [:pointer, :int], :int attach_function :inflateEnd, [:pointer], :int attach_function :inflateReset, [:pointer], :int attach_function :inflateSetDictionary, [:pointer, :string, :uint], :int attach_function :adler32_c, :adler32, [:ulong, :string, :uint], :ulong attach_function :crc32_c, :crc32, [:ulong, :string, :uint], :ulong attach_function :get_crc_table_c, :get_crc_table, [], :pointer attach_function :zError, [:int], :string # Chunk size for inflation and deflation CHUNK = 1024 #-- # HACK from zlib.c #++ GZ_EXTRAFLAG_FAST = 0x4 GZ_EXTRAFLAG_SLOW = 0x2 ## # Zlib::Deflate is the class for compressing data. See Zlib::ZStream for # more information. class Deflate < ZStream ## # Compresses the given +string+. Valid values of level are # <tt>Zlib::NO_COMPRESSION</tt>, <tt>Zlib::BEST_SPEED</tt>, # <tt>Zlib::BEST_COMPRESSION</tt>, <tt>Zlib::DEFAULT_COMPRESSION</tt>, and # an integer from 0 to 9. # # This method is almost equivalent to the following code: # # def deflate(string, level) # z = Zlib::Deflate.new(level) # dst = z.deflate(string, Zlib::FINISH) # z.close # dst # end def self.deflate(data, level = Zlib::DEFAULT_COMPRESSION) deflator = new level zipped = deflator.deflate data, Zlib::FINISH zipped ensure deflator.end end ## # Creates a new deflate stream for compression. See zlib.h for details of # each argument. If an argument is nil, the default value of that argument # is used. def initialize(level = Zlib::DEFAULT_COMPRESSION, window_bits = Zlib::MAX_WBITS, mem_level = Zlib::DEF_MEM_LEVEL, strategy = Zlib::DEFAULT_STRATEGY) level ||= Zlib::DEFAULT_COMPRESSION window_bits ||= Zlib::MAX_WBITS mem_level ||= Zlib::DEF_MEM_LEVEL strategy ||= Zlib::DEFAULT_STRATEGY super() @func_end = :deflateEnd @func_reset = :deflateReset @func_run = :deflate err = Zlib.deflateInit2(pointer, level, Zlib::DEFLATED, window_bits, mem_level, strategy) Zlib.handle_error err, message ready end ## # Same as IO. def <<(data) do_deflate data, Zlib::NO_FLUSH self end ## # Inputs +string+ into the deflate stream and returns the output from the # stream. On calling this method, both the input and the output buffers # of the stream are flushed. If +string+ is nil, this method finishes the # stream, just like Zlib::ZStream#finish. # # The value of +flush+ should be either <tt>Zlib::NO_FLUSH</tt>, # <tt>Zlib::SYNC_FLUSH</tt>, <tt>Zlib::FULL_FLUSH</tt>, or # <tt>Zlib::FINISH</tt>. See zlib.h for details. def deflate(data, flush = Zlib::NO_FLUSH) do_deflate data, flush detatch_output end ## # Performs the deflate operation and leaves the compressed data in the # output buffer def do_deflate(data, flush) if data.nil? then run '', Zlib::FINISH else data = StringValue data if flush != Zlib::NO_FLUSH or not data.empty? then # prevent BUF_ERROR run data, flush end end end ## # Finishes compressing the deflate input stream and returns the output # buffer. def finish run '', Zlib::FINISH detatch_output end ## # This method is equivalent to <tt>deflate('', flush)</tt>. If flush is # omitted, <tt>Zlib::SYNC_FLUSH</tt> is used as flush. This method is # just provided to improve the readability of your Ruby program. def flush(flush = Zlib::SYNC_FLUSH) run '', flush unless flush == Zlib::NO_FLUSH detatch_output end ## # Changes the parameters of the deflate stream. See zlib.h for details. # The output from the stream by changing the params is preserved in output # buffer. def params(level, strategy) err = Zlib.deflateParams pointer, level, strategy raise Zlib::BufError, 'buffer expansion not implemented' if err == Zlib::BUF_ERROR Zlib.handle_error err, message nil end ## # Sets the preset dictionary and returns +dictionary+. This method is # available just only after Zlib::Deflate.new or Zlib::ZStream#reset # method was called. See zlib.h for details. def set_dictionary(dictionary) dict = StringValue dictionary err = Zlib.deflateSetDictionary pointer, dict, dict.length Zlib.handle_error err, message dictionary end end ## # Zlib::GzipFile is an abstract class for handling a gzip formatted # compressed file. The operations are defined in the subclasses, # Zlib::GzipReader for reading, and Zlib::GzipWriter for writing. # # GzipReader should be used by associating an IO, or IO-like, object. class GzipFile SYNC = Zlib::ZStream::UNUSED HEADER_FINISHED = Zlib::ZStream::UNUSED << 1 FOOTER_FINISHED = Zlib::ZStream::UNUSED << 2 FLAG_MULTIPART = 0x2 FLAG_EXTRA = 0x4 FLAG_ORIG_NAME = 0x8 FLAG_COMMENT = 0x10 FLAG_ENCRYPT = 0x20 FLAG_UNKNOWN_MASK = 0xc0 EXTRAFLAG_FAST = 0x4 EXTRAFLAG_SLOW = 0x2 MAGIC1 = 0x1f MAGIC2 = 0x8b METHOD_DEFLATE = 8 ## # Base class of errors that occur when processing GZIP files. class Error < Zlib::Error; end ## # Raised when gzip file footer is not found. class NoFooter < Error; end ## # Raised when the CRC checksum recorded in gzip file footer is not # equivalent to the CRC checksum of the actual uncompressed data. class CRCError < Error; end ## # Raised when the data length recorded in the gzip file footer is not # equivalent to the length of the actual uncompressed data. class LengthError < Error; end ## # Accessor for the underlying ZStream attr_reader :zstream # :nodoc: ## # See Zlib::GzipReader#wrap and Zlib::GzipWriter#wrap. def self.wrap(*args) obj = new(*args) if block_given? then begin yield obj ensure obj.close if obj.zstream.ready? end end end def initialize @comment = nil @crc = 0 @level = nil @mtime = Time.at 0 @orig_name = nil @os_code = Zlib::OS_CODE end ## # Closes the GzipFile object. This method calls close method of the # associated IO object. Returns the associated IO object. def close io = finish io.close if io.respond_to? :close io end ## # Same as IO def closed? @io.nil? end ## # Returns comments recorded in the gzip file header, or nil if the # comment is not present. def comment raise Error, 'closed gzip stream' if @io.nil? @comment.dup end def end return if @zstream.closing? @zstream.flags |= Zlib::ZStream::CLOSING begin end_run ensure @zstream.end end end ## # Closes the GzipFile object. Unlike Zlib::GzipFile#close, this method # never calls the close method of the associated IO object. Returns the # associated IO object. def finish self.end io = @io @io = nil @orig_name = nil @comment = nil io end def finished? @zstream.finished? and @zstream.output.empty? # HACK I think end def footer_finished? @zstream.flags & Zlib::GzipFile::FOOTER_FINISHED == Zlib::GzipFile::FOOTER_FINISHED end def header_finished? @zstream.flags & Zlib::GzipFile::HEADER_FINISHED == Zlib::GzipFile::HEADER_FINISHED end ## # Returns last modification time recorded in the gzip file header. def mtime Time.at @mtime end ## # Returns original filename recorded in the gzip file header, or +nil+ if # original filename is not present. def orig_name raise Error, 'closed gzip stream' if @io.nil? @orig_name.dup end end ## # Zlib::GzipReader is the class for reading a gzipped file. GzipReader # should be used an IO, or -IO-lie, object. # # Zlib::GzipReader.open('hoge.gz') {|gz| # print gz.read # } # # File.open('hoge.gz') do |f| # gz = Zlib::GzipReader.new(f) # print gz.read # gz.close # end # # == Method Catalogue # # The following methods in Zlib::GzipReader are just like their counterparts # in IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an # error was found in the gzip file. # # - #each # - #each_line # - #each_byte # - #gets # - #getc # - #lineno # - #lineno= # - #read # - #readchar # - #readline # - #readlines # - #ungetc # # Be careful of the footer of the gzip file. A gzip file has the checksum of # pre-compressed data in its footer. GzipReader checks all uncompressed data # against that checksum at the following cases, and if it fails, raises # <tt>Zlib::GzipFile::NoFooter</tt>, <tt>Zlib::GzipFile::CRCError</tt>, or # <tt>Zlib::GzipFile::LengthError</tt> exception. # # - When an reading request is received beyond the end of file (the end of # compressed data). That is, when Zlib::GzipReader#read, # Zlib::GzipReader#gets, or some other methods for reading returns nil. # - When Zlib::GzipFile#close method is called after the object reaches the # end of file. # - When Zlib::GzipReader#unused method is called after the object reaches # the end of file. # # The rest of the methods are adequately described in their own # documentation. class GzipReader < GzipFile # HACK use a buffer class ## # Creates a GzipReader object associated with +io+. The GzipReader object # reads gzipped data from +io+, and parses/decompresses them. At least, # +io+ must have a +read+ method that behaves same as the +read+ method in # IO class. # # If the gzip file header is incorrect, raises an Zlib::GzipFile::Error # exception. def initialize(io) @io = io @zstream = Zlib::Inflate.new -Zlib::MAX_WBITS @buffer = '' super() read_header end def check_footer @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED footer = @zstream.input.slice! 0, 8 rest = @io.read 8 - footer.length footer << rest if rest raise NoFooter, 'footer is not found' unless footer.length == 8 crc, length = footer.unpack 'VV' @zstream[:total_in] += 8 # to rewind correctly raise CRCError, 'invalid compressed data -- crc error' unless @crc == crc raise LengthError, 'invalid compressed data -- length error' unless length == @zstream.total_out end def end_run check_footer if @zstream.finished? and not footer_finished? end def eof? @zstream.finished? and @zstream.input_empty? end def pos @zstream[:total_out] - @buffer.length end ## # See Zlib::GzipReader documentation for a description. def read(length = nil) data = @buffer while chunk = @io.read(CHUNK) do inflated = @zstream.inflate(chunk) @crc = Zlib.crc32 inflated, @crc data << inflated break if length and data.length > length end if length then @buffer = data.slice! length..-1 else @buffer = '' end check_footer if @zstream.finished? and not footer_finished? data rescue Zlib::Error => e raise GzipFile::Error, e.message end def read_header header = @io.read 10 raise Error, 'not in gzip format' unless header.length == 10 magic1, magic2, method, flags, @mtime, extra_flags, @os_code = header.unpack 'CCCCVCC' unless magic1 == Zlib::GzipFile::MAGIC1 and magic2 == Zlib::GzipFile::MAGIC2 then raise Error, 'not in gzip format' end unless method == Zlib::GzipFile::METHOD_DEFLATE then raise Error, "unsupported compression method #{method}" end if flags & Zlib::GzipFile::FLAG_MULTIPART == Zlib::GzipFile::FLAG_MULTIPART then raise Error, 'multi-part gzip file is not supported' end if flags & Zlib::GzipFile::FLAG_ENCRYPT == Zlib::GzipFile::FLAG_ENCRYPT then raise Error, 'encrypted gzip file is not supported' end if flags & Zlib::GzipFile::FLAG_UNKNOWN_MASK == Zlib::GzipFile::FLAG_UNKNOWN_MASK then raise Error, "unknown flags 0x#{flags.to_s 16}" end if extra_flags & Zlib::GzipFile::EXTRAFLAG_FAST == Zlib::GzipFile::EXTRAFLAG_FAST then @level = Zlib::BEST_SPEED elsif extra_flags & Zlib::GzipFile::EXTRAFLAG_SLOW == Zlib::GzipFile::EXTRAFLAG_SLOW then @level = Zlib::BEST_COMPRESSION else @level = Zlib::DEFAULT_COMPRESSION end if flags & Zlib::GzipFile::FLAG_EXTRA == Zlib::GzipFile::FLAG_EXTRA then length = @io.read 2 raise Zlib::GzipFile::Error, 'unexpected end of file' if length.nil? or length.length != 2 length, = length.unpack 'v' extra = @io.read length + 2 raise Zlib::GzipFile::Error, 'unexpected end of file' if extra.nil? or extra.length != length + 2 end if flags & Zlib::GzipFile::FLAG_ORIG_NAME == Zlib::GzipFile::FLAG_ORIG_NAME then @orig_name = '' c = @io.getc until c == 0 do @orig_name << c.chr c = @io.getc end end if flags & Zlib::GzipFile::FLAG_COMMENT == Zlib::GzipFile::FLAG_COMMENT then @comment = '' c = @io.getc until c == 0 do @comment << c.chr c = @io.getc end end end end ## # Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should # be used with an instance of IO, or IO-like, object. # # For example: # # Zlib::GzipWriter.open('hoge.gz') do |gz| # gz.write 'jugemu jugemu gokou no surikire...' # end # # File.open('hoge.gz', 'w') do |f| # gz = Zlib::GzipWriter.new(f) # gz.write 'jugemu jugemu gokou no surikire...' # gz.close # end # # NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close # GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter # will be not able to write the gzip footer and will generate a broken gzip # file. class GzipWriter < GzipFile # HACK use a buffer class ## # Set the comment attr_writer :comment ## # Set the original name attr_writer :orig_name ## # Creates a GzipWriter object associated with +io+. +level+ and +strategy+ # should be the same as the arguments of Zlib::Deflate.new. The # GzipWriter object writes gzipped data to +io+. At least, +io+ must # respond to the +write+ method that behaves same as write method in IO # class. def initialize(io, level = Zlib::DEFAULT_COMPRESSION, strategy = Zlib::DEFAULT_STRATEGY) @io = io @zstream = Zlib::Deflate.new level, -Zlib::MAX_WBITS, Zlib::DEF_MEM_LEVEL, strategy @buffer = '' super() end def end_run make_header unless header_finished? @zstream.run '', Zlib::FINISH write_raw make_footer nil end ## # Flushes all the internal buffers of the GzipWriter object. The meaning # of +flush+ is same as in Zlib::Deflate#deflate. # <tt>Zlib::SYNC_FLUSH</tt> is used if +flush+ is omitted. It is no use # giving flush <tt>Zlib::NO_FLUSH</tt>. def flush true end ## # Writes out a gzip header def make_header flags = 0 extra_flags = 0 flags |= Zlib::GzipFile::FLAG_ORIG_NAME if @orig_name flags |= Zlib::GzipFile::FLAG_COMMENT if @comment extra_flags |= Zlib::GzipFile::EXTRAFLAG_FAST if @level == Zlib::BEST_SPEED extra_flags |= Zlib::GzipFile::EXTRAFLAG_SLOW if @level == Zlib::BEST_COMPRESSION header = [ Zlib::GzipFile::MAGIC1, # byte 0 Zlib::GzipFile::MAGIC2, # byte 1 Zlib::GzipFile::METHOD_DEFLATE, # byte 2 flags, # byte 3 @mtime.to_i, # bytes 4-7 extra_flags, # byte 8 @os_code # byte 9 ].pack 'CCCCVCC' @io.write header @io.write "#{@orig_name}\0" if @orig_name @io.write "#{@comment}\0" if @comment @zstream.flags |= Zlib::GzipFile::HEADER_FINISHED end ## # Writes out a gzip footer def make_footer footer = [ @crc, # bytes 0-3 @zstream.total_in, # bytes 4-7 ].pack 'VV' @io.write footer @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED end ## # Sets the modification time of this file def mtime=(time) if header_finished? then raise Zlib::GzipFile::Error, 'header is already written' end @mtime = Integer time end def sync? @zstream.flags & Zlib::GzipFile::SYNC == Zlib::GzipFile::SYNC end ## # Same as IO. def write(data) make_header unless header_finished? data = String data if data.length > 0 or sync? then @crc = Zlib.crc32_c @crc, data, data.length flush = sync? ? Zlib::SYNC_FLUSH : Zlib::NO_FLUSH @zstream.run data, flush end write_raw end ## # Same as IO. alias << write def write_raw data = @zstream.detatch_output unless data.empty? then @io.write data @io.flush if sync? and io.respond_to :flush end end end ## # Zlib:Inflate is the class for decompressing compressed data. Unlike # Zlib::Deflate, an instance of this class is not able to duplicate (clone, # dup) itself. class Inflate < ZStream ## # Decompresses +string+. Raises a Zlib::NeedDict exception if a preset # dictionary is needed for decompression. # # This method is almost equivalent to the following code: # # def inflate(string) # zstream = Zlib::Inflate.new # buf = zstream.inflate(string) # zstream.finish # zstream.close # buf # end def self.inflate(data) inflator = new unzipped = inflator.inflate data unzipped ensure inflator.end end ## # Creates a new inflate stream for decompression. See zlib.h for details # of the argument. If +window_bits+ is +nil+, the default value is used. def initialize(window_bits = Zlib::MAX_WBITS) super() @func_end = :inflateEnd @func_reset = :inflateReset @func_run = :inflate err = Zlib.inflateInit2 pointer, window_bits Zlib.handle_error err, message # HACK ready end ## # Inputs +string+ into the inflate stream just like Zlib::Inflate#inflate, # but returns the Zlib::Inflate object itself. The output from the stream # is preserved in output buffer. def <<(string) string = StringValue string unless string.nil? if finished? then unless string.nil? then @input ||= '' @input << string end else run string, Zlib::SYNC_FLUSH end end ## # Inputs +string+ into the inflate stream and returns the output from the # stream. Calling this method, both the input and the output buffer of # the stream are flushed. If string is +nil+, this method finishes the
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
true
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/powerpc-darwin/sysconf.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/powerpc-darwin/sysconf.rb
# This file is generated by rake. Do not edit. module Platform;end module Platform::Sysconf SC_2_CHAR_TERM = 20 SC_2_C_BIND = 18 SC_2_C_DEV = 19 SC_2_FORT_DEV = 21 SC_2_FORT_RUN = 22 SC_2_LOCALEDEF = 23 SC_2_PBS = 59 SC_2_PBS_ACCOUNTING = 60 SC_2_PBS_CHECKPOINT = 61 SC_2_PBS_LOCATE = 62 SC_2_PBS_MESSAGE = 63 SC_2_PBS_TRACK = 64 SC_2_SW_DEV = 24 SC_2_UPE = 25 SC_2_VERSION = 17 SC_ADVISORY_INFO = 65 SC_AIO_LISTIO_MAX = 42 SC_AIO_MAX = 43 SC_AIO_PRIO_DELTA_MAX = 44 SC_ARG_MAX = 1 SC_ASYNCHRONOUS_IO = 28 SC_ATEXIT_MAX = 107 SC_BARRIERS = 66 SC_BC_BASE_MAX = 9 SC_BC_DIM_MAX = 10 SC_BC_SCALE_MAX = 11 SC_BC_STRING_MAX = 12 SC_CHILD_MAX = 2 SC_CLK_TCK = 3 SC_CLOCK_SELECTION = 67 SC_COLL_WEIGHTS_MAX = 13 SC_CPUTIME = 68 SC_DELAYTIMER_MAX = 45 SC_EXPR_NEST_MAX = 14 SC_FILE_LOCKING = 69 SC_FSYNC = 38 SC_GETGR_R_SIZE_MAX = 70 SC_GETPW_R_SIZE_MAX = 71 SC_HOST_NAME_MAX = 72 SC_IOV_MAX = 56 SC_IPV6 = 118 SC_JOB_CONTROL = 6 SC_LINE_MAX = 15 SC_LOGIN_NAME_MAX = 73 SC_MAPPED_FILES = 47 SC_MEMLOCK = 30 SC_MEMLOCK_RANGE = 31 SC_MEMORY_PROTECTION = 32 SC_MESSAGE_PASSING = 33 SC_MONOTONIC_CLOCK = 74 SC_MQ_OPEN_MAX = 46 SC_MQ_PRIO_MAX = 75 SC_NGROUPS_MAX = 4 SC_NPROCESSORS_CONF = 57 SC_NPROCESSORS_ONLN = 58 SC_OPEN_MAX = 5 SC_PAGESIZE = 29 SC_PAGE_SIZE = 29 SC_PASS_MAX = 131 SC_PRIORITIZED_IO = 34 SC_PRIORITY_SCHEDULING = 35 SC_RAW_SOCKETS = 119 SC_READER_WRITER_LOCKS = 76 SC_REALTIME_SIGNALS = 36 SC_REGEXP = 77 SC_RE_DUP_MAX = 16 SC_RTSIG_MAX = 48 SC_SAVED_IDS = 7 SC_SEMAPHORES = 37 SC_SEM_NSEMS_MAX = 49 SC_SEM_VALUE_MAX = 50 SC_SHARED_MEMORY_OBJECTS = 39 SC_SHELL = 78 SC_SIGQUEUE_MAX = 51 SC_SPAWN = 79 SC_SPIN_LOCKS = 80 SC_SPORADIC_SERVER = 81 SC_SS_REPL_MAX = 126 SC_STREAM_MAX = 26 SC_SYMLOOP_MAX = 120 SC_SYNCHRONIZED_IO = 40 SC_THREADS = 96 SC_THREAD_ATTR_STACKADDR = 82 SC_THREAD_ATTR_STACKSIZE = 83 SC_THREAD_CPUTIME = 84 SC_THREAD_DESTRUCTOR_ITERATIONS = 85 SC_THREAD_KEYS_MAX = 86 SC_THREAD_PRIORITY_SCHEDULING = 89 SC_THREAD_PRIO_INHERIT = 87 SC_THREAD_PRIO_PROTECT = 88 SC_THREAD_PROCESS_SHARED = 90 SC_THREAD_SAFE_FUNCTIONS = 91 SC_THREAD_SPORADIC_SERVER = 92 SC_THREAD_STACK_MIN = 93 SC_THREAD_THREADS_MAX = 94 SC_TIMEOUTS = 95 SC_TIMERS = 41 SC_TIMER_MAX = 52 SC_TRACE = 97 SC_TRACE_EVENT_FILTER = 98 SC_TRACE_EVENT_NAME_MAX = 127 SC_TRACE_INHERIT = 99 SC_TRACE_LOG = 100 SC_TRACE_NAME_MAX = 128 SC_TRACE_SYS_MAX = 129 SC_TRACE_USER_EVENT_MAX = 130 SC_TTY_NAME_MAX = 101 SC_TYPED_MEMORY_OBJECTS = 102 SC_TZNAME_MAX = 27 SC_V6_ILP32_OFF32 = 103 SC_V6_ILP32_OFFBIG = 104 SC_V6_LP64_OFF64 = 105 SC_V6_LPBIG_OFFBIG = 106 SC_VERSION = 8 SC_XBS5_ILP32_OFF32 = 122 SC_XBS5_ILP32_OFFBIG = 123 SC_XBS5_LP64_OFF64 = 124 SC_XBS5_LPBIG_OFFBIG = 125 SC_XOPEN_CRYPT = 108 SC_XOPEN_ENH_I18N = 109 SC_XOPEN_LEGACY = 110 SC_XOPEN_REALTIME = 111 SC_XOPEN_REALTIME_THREADS = 112 SC_XOPEN_SHM = 113 SC_XOPEN_STREAMS = 114 SC_XOPEN_UNIX = 115 SC_XOPEN_VERSION = 116 SC_XOPEN_XCU_VERSION = 121 end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/java/inspect.rb
tools/jruby-1.5.1/lib/ruby/site_ruby/shared/java/inspect.rb
require 'jruby' class Java::JavaLang::Object def inspect() # '<#Java::MyPackage::TheClass:0xDECAFBAD ' header = "#<#{self.class}:0x#{Java::JavaLang::System::identity_hash_code(self).to_s(16)} " # Bail quickly if looping return header + "...>" if JRuby.runtime.inspecting?(self) begin fs = self.java_class.declared_fields # get fields fvals = [] JRuby.runtime.register_inspecting(self) # loop protection fs.each do |f| f.accessible=true # let us prod everything. Invasive :-( fvals << "@#{f.name} = #{f.value(self).inspect}" if !f.static? end header + "#{fvals.join(', ')}>" ensure JRuby.runtime.unregister_inspecting(self) # undo loop protection end end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/app/controllers/protected_resource_controller.rb
provider/app/controllers/protected_resource_controller.rb
# Copyright (c) 2010 ThoughtWorks Inc. (http://thoughtworks.com) # Licenced under the MIT License (http://www.opensource.org/licenses/mit-license.php) class ProtectedResourceController < ApplicationController oauth_allowed :only => :index def index render :text => "current user is #{current_user.email}" end def no_oauth_here render :text => "this content not available via Oauth" end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/app/controllers/users_controller.rb
provider/app/controllers/users_controller.rb
# Copyright (c) 2010 ThoughtWorks Inc. (http://thoughtworks.com) # Licenced under the MIT License (http://www.opensource.org/licenses/mit-license.php) class UsersController < ApplicationController skip_before_filter :login_required, :only => [:new, :create] # GET /users # GET /users.xml def index @users = User.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @users } end end # GET /users/1 # GET /users/1.xml def show @user = User.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @user } end end # GET /users/new # GET /users/new.xml def new @user = User.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @user } end end # GET /users/1/edit def edit @user = User.find(params[:id]) end # POST /users # POST /users.xml def create @user = User.new(params[:user]) respond_to do |format| if @user.save flash[:notice] = 'User was successfully created.' format.html { redirect_to(@user) } format.xml { render :xml => @user, :status => :created, :location => @user } else format.html { render :action => "new" } format.xml { render :xml => @user.errors, :status => :unprocessable_entity } end end end # PUT /users/1 # PUT /users/1.xml def update @user = User.find(params[:id]) respond_to do |format| if @user.update_attributes(params[:user]) flash[:notice] = 'User was successfully updated.' format.html { redirect_to(@user) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @user.errors, :status => :unprocessable_entity } end end end # DELETE /users/1 # DELETE /users/1.xml def destroy @user = User.find(params[:id]) @user.destroy respond_to do |format| format.html { redirect_to(users_url) } format.xml { head :ok } end end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/app/controllers/sessions_controller.rb
provider/app/controllers/sessions_controller.rb
# Copyright (c) 2010 ThoughtWorks Inc. (http://thoughtworks.com) # Licenced under the MIT License (http://www.opensource.org/licenses/mit-license.php) class SessionsController < ApplicationController skip_before_filter :login_required, :only => ['index', 'create'] def index # renders the login page end def create if user = User.authenticate(params[:email], params[:password]) self.current_user = user flash[:notice] = 'Welcome!' redirect_to(session[:redirect_to] || '/') return else flash.now[:error] = "Couldn't locate a user with those credentials" redirect_to :action => :index end end def clear_session self.clear_current_user redirect_to :action => :index end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/app/controllers/application_controller.rb
provider/app/controllers/application_controller.rb
# Copyright (c) 2010 ThoughtWorks Inc. (http://thoughtworks.com) # Licenced under the MIT License (http://www.opensource.org/licenses/mit-license.php) # Filters added to this controller apply to all controllers in the application. # Likewise, all the methods added will be available for all controllers. class ApplicationController < ActionController::Base helper :all # include all helpers, all the time # protect_from_forgery # See ActionController::RequestForgeryProtection for details # Scrub sensitive parameters from your log filter_parameter_logging :password # include ApplicationController workings required for Oauth2 plugin include Oauth2::Provider::ApplicationControllerMethods # part of sample host app's hand-rolled authentication 'system' :) before_filter :login_required # part of sample host app's hand-rolled authentication 'system' :) def logged_in? !current_user.nil? end # part of sample host app's hand-rolled authentication 'system' :) def current_user @__current_user ||= User.find_by_id(session[:user_id]) end protected def login_required session[:redirect_to] = request.request_uri valid_basic_auth_user = authenticate_with_http_basic do |username, password| user = User.find_by_email_and_password(username, password) if user current_user = user end user end valid_basic_auth_user || login_required_with_form end # part of sample host app's hand-rolled authentication 'system' :) def login_required_with_form redirect_to :controller => 'sessions', :action => 'index' unless logged_in? end # part of sample host app's hand-rolled authentication 'system' :) def current_user=(user) session[:user_id] = user.id @__current_user = user end # part of sample host app's hand-rolled authentication 'system' :) def clear_current_user session.delete(:user_id) @__current_user = nil end # required by Oauth2 plugin, returns user id that will # serve as foreign key to authorize codes and access tokens def current_user_id_for_oauth current_user.id.to_s end # required for oauth to actually work, we wrap our non-oauth # authentication filter with an opportunity to first determine # the request's user via an oauth header. def login_required_with_oauth if user_id = self.user_id_for_oauth_access_token session[:user_id] = user_id elsif looks_like_oauth_request? render :text => "Denied!", :status => :unauthorized else login_required_without_oauth end end alias_method_chain :login_required, :oauth end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/app/models/user.rb
provider/app/models/user.rb
# Copyright (c) 2010 ThoughtWorks Inc. (http://thoughtworks.com) # Licenced under the MIT License (http://www.opensource.org/licenses/mit-license.php) class User < ActiveRecord::Base def self.authenticate(email, password) User.find_by_email_and_password(email, password) end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/vendor/gems/validatable-1.6.7/rakefile.rb
provider/vendor/gems/validatable-1.6.7/rakefile.rb
require 'rubygems' require 'rake/gempackagetask' require 'rake/rdoctask' require 'rake/contrib/sshpublisher' task :default => :test task :test do require File.dirname(__FILE__) + '/test/all_tests.rb' end desc 'Generate RDoc' Rake::RDocTask.new do |task| task.main = 'README' task.title = 'Validatable' task.rdoc_dir = 'doc' task.options << "--line-numbers" << "--inline-source" task.rdoc_files.include('README', 'lib/**/*.rb') %x[erb README_TEMPLATE > README] if File.exists?('README_TEMPLATE') end desc "Upload RDoc to RubyForge" task :publish_rdoc => [:rdoc] do Rake::SshDirPublisher.new("jaycfields@rubyforge.org", "/var/www/gforge-projects/validatable", "doc").upload end Gem::manage_gems specification = Gem::Specification.new do |s| s.name = "validatable" s.summary = "Validatable is a library for adding validations." s.version = "1.6.7" s.author = 'Jay Fields' s.description = "Validatable is a library for adding validations." s.email = 'validatable-developer@rubyforge.org' s.homepage = 'http://validatable.rubyforge.org' s.rubyforge_project = 'validatable' s.has_rdoc = true s.extra_rdoc_files = ['README'] s.rdoc_options << '--title' << 'Validatable' << '--main' << 'README' << '--line-numbers' s.files = FileList['{lib,test}/**/*.rb', '[A-Z]*$', 'rakefile.rb'].to_a s.test_file = "test/all_tests.rb" end Rake::GemPackageTask.new(specification) do |package| package.need_zip = false package.need_tar = false end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/vendor/gems/validatable-1.6.7/test/test_helper.rb
provider/vendor/gems/validatable-1.6.7/test/test_helper.rb
require 'test/unit' require 'rubygems' require 'mocha' require 'dust' require 'set' require 'expectations' require File.dirname(__FILE__) + '/../lib/validatable' class << Test::Unit::TestCase def expect(expected_value, &block) define_method :"test_#{caller.first.split("/").last}" do begin assert_equal expected_value, instance_eval(&block) rescue Exception => ex raise ex unless expected_value.is_a?(Class) && ex.is_a?(expected_value) assert_equal expected_value, ex.class end end end end class Test::Unit::TestCase def assert_array_equal a, b assert_equal Set.new(a), Set.new(b) end end class Array def to_blank_options_hash self.inject({}) {|hash, value| hash[value] = nil; hash } end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/vendor/gems/validatable-1.6.7/test/all_tests.rb
provider/vendor/gems/validatable-1.6.7/test/all_tests.rb
Dir['test/**/*_test.rb'].each { |test_case| require test_case }
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/vendor/gems/validatable-1.6.7/test/unit/errors_test.rb
provider/vendor/gems/validatable-1.6.7/test/unit/errors_test.rb
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') Expectations do expect "message" do errors = Validatable::Errors.new errors.add(:attribute, "message") errors.on(:attribute) end expect ["message"] do errors = Validatable::Errors.new errors.add(:attribute, "message") errors.raw(:attribute) end expect "something new" do errors = Validatable::Errors.new errors.add(:attribute, "something old") errors.replace(:attribute, ["something new"]) errors.on(:attribute) end expect "Capitalized word" do errors = Validatable::Errors.new errors.humanize("capitalized_word") end expect "Capitalized word without" do errors = Validatable::Errors.new errors.humanize("capitalized_word_without_id") end expect ["A humanized message", "a base message"] do errors = Validatable::Errors.new errors.add(:base, "a base message") errors.add(:a_humanized, "message") errors.full_messages.sort end expect true do Validatable::Errors.included_modules.include?(Enumerable) end expect ["message1", "message2"] do errors = Validatable::Errors.new errors.add(:attribute, "message1") errors.add(:attribute, "message2") errors.on(:attribute) end expect 2 do errors = Validatable::Errors.new errors.add(:attribute, "message1") errors.add(:attribute, "message2") errors.count end expect 2 do errors = Validatable::Errors.new errors.add(:attribute1, "message1") errors.add(:attribute2, "message2") errors.count end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/vendor/gems/validatable-1.6.7/test/unit/validates_format_of_test.rb
provider/vendor/gems/validatable-1.6.7/test/unit/validates_format_of_test.rb
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') Expectations do expect false do validation = Validatable::ValidatesFormatOf.new stub_everything, :name, :with => /book/ validation.valid?(stub_everything) end expect true do validation = Validatable::ValidatesFormatOf.new stub_everything, :name, :with => /book/ validation.valid?(stub(:name=>"book")) end expect true do validation = Validatable::ValidatesFormatOf.new stub_everything, :age, :with => /14/ validation.valid?(stub(:age=>14)) end expect ArgumentError do validation = Validatable::ValidatesFormatOf.new stub_everything, :age end expect true do options = [:message, :if, :times, :level, :groups, :with, :key] Validatable::ValidatesFormatOf.new(stub_everything, :test, options.to_blank_options_hash).must_understand(options.to_blank_options_hash) end expect true do options = [:with] Validatable::ValidatesFormatOf.new(stub_everything, :name, options.to_blank_options_hash).requires(options.to_blank_options_hash) end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/vendor/gems/validatable-1.6.7/test/unit/validates_true_for_test.rb
provider/vendor/gems/validatable-1.6.7/test/unit/validates_true_for_test.rb
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') Expectations do expect false do validation = Validatable::ValidatesTrueFor.new stub_everything, :name, :logic => lambda { false } validation.valid?(stub_everything) end expect true do validation = Validatable::ValidatesTrueFor.new stub_everything, :name, :logic => lambda { true } validation.valid?(stub_everything) end expect ArgumentError do validation = Validatable::ValidatesTrueFor.new stub_everything, :age end expect true do options = [:message, :if, :times, :level, :groups, :logic, :key] Validatable::ValidatesTrueFor.new(stub_everything, :name, options.to_blank_options_hash).must_understand(options.to_blank_options_hash) end expect true do options = [:logic] Validatable::ValidatesTrueFor.new(stub_everything, :name, options.to_blank_options_hash).requires(options.to_blank_options_hash) end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/vendor/gems/validatable-1.6.7/test/unit/validates_acceptance_of_test.rb
provider/vendor/gems/validatable-1.6.7/test/unit/validates_acceptance_of_test.rb
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') Expectations do expect true do validation = Validatable::ValidatesAcceptanceOf.new stub_everything, :acceptance instance = stub(:acceptance=>'true') validation.valid?(instance) end expect false do validation = Validatable::ValidatesAcceptanceOf.new stub_everything, :acceptance instance = stub(:acceptance=>'false') validation.valid?(instance) end expect true do options = {:message => nil, :if => nil, :times => nil, :level => nil, :groups => nil} Validatable::ValidatesAcceptanceOf.new(stub_everything, :test).must_understand(options) end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/vendor/gems/validatable-1.6.7/test/unit/validates_confirmation_of_test.rb
provider/vendor/gems/validatable-1.6.7/test/unit/validates_confirmation_of_test.rb
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') Expectations do expect true do validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username instance = stub(:username=>"username", :username_confirmation=>"username") validation.valid?(instance) end expect false do validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username instance = stub(:username=>"username", :username_confirmation=>"usessrname") validation.valid?(instance) end expect true do validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username, :case_sensitive => false instance = stub(:username=>"username", :username_confirmation=>"USERNAME") validation.valid?(instance) end expect false do validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username, :case_sensitive => true instance = stub(:username=>"username", :username_confirmation=>"USERNAME") validation.valid?(instance) end expect false do validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username, :case_sensitive => true validation.valid?(stub(:username => nil, :username_confirmation => 'something')) end expect false do validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username, :case_sensitive => true validation.valid?(stub(:username => 'something', :username_confirmation => nil)) end expect true do validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username, :case_sensitive => true validation.valid?(stub(:username => nil, :username_confirmation => nil)) end expect false do validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username, :case_sensitive => false validation.valid?(stub(:username => nil, :username_confirmation => 'something')) end expect false do validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username, :case_sensitive => false validation.valid?(stub(:username => 'something', :username_confirmation => nil)) end expect true do validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username, :case_sensitive => false validation.valid?(stub(:username => nil, :username_confirmation => nil)) end expect true do options = { :message => nil, :if => nil, :times => nil, :level => nil, :groups => nil, :case_sensitive => nil } Validatable::ValidatesConfirmationOf.new(stub_everything, :test).must_understand(options) end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/vendor/gems/validatable-1.6.7/test/unit/validation_base_test.rb
provider/vendor/gems/validatable-1.6.7/test/unit/validation_base_test.rb
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') Expectations do expect true do validation = Validatable::ValidationBase.new stub_everything, :base validation.should_validate? Object.new end expect true do validation = Validatable::ValidationBase.new stub_everything, :base, :times => 1 validation.validate_this_time?(stub(:times_validated => 0)) end expect true do validation = Validatable::ValidationBase.new stub_everything, :base validation.validate_this_time?(nil) end expect true do validation = Validatable::ValidationBase.new stub_everything, :base, :times => 2 validation.validate_this_time?(stub(:times_validated => 1)) end expect false do validation = Validatable::ValidationBase.new stub_everything, :base, :times => 1 validation.validate_this_time?(stub(:times_validated => 1)) end expect 1 do validation = Validatable::ValidationBase.new stub_everything, :base validation.level end expect ArgumentError do Validatable::ValidationBase.new stub_everything(:validation_keys_include? => true), :base, :times => 1 end expect "some message 100" do validation = Validatable::ValidationBase.new stub_everything, :base, :message => lambda { "some message #{a_method}" } validation.message(stub(:a_method=>'100')) end expect ArgumentError do Validatable::ValidationBase.new(stub_everything, :base).must_understand(:foo => 1, :bar => 2) end expect true do options = {:message => nil, :if => nil, :times => nil, :level => nil, :groups => nil, :key => nil} Validatable::ValidationBase.new(stub_everything, :base).must_understand(options) end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/vendor/gems/validatable-1.6.7/test/unit/validates_length_of_test.rb
provider/vendor/gems/validatable-1.6.7/test/unit/validates_length_of_test.rb
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') Expectations do expect false do validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :maximum => 8 validation.valid?(stub(:username=>"usernamefdfd")) end expect false do validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :minimum => 2 instance = stub(:username=>"u") validation.valid?(instance) end expect true do validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :minimum => 2, :maximum => 8 instance = stub(:username=>"udfgdf") validation.valid?(instance) end expect false do validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :is => 2 instance = stub(:username=>"u") validation.valid?(instance) end expect true do validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :is => 2 instance = stub(:username=>"uu") validation.valid?(instance) end expect true do validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :within => 2..4 instance = stub(:username => "aa") validation.valid?(instance) end expect false do validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :within => 2..4 instance = stub(:username => "a") validation.valid?(instance) end expect true do validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :within => 2..4 instance = stub(:username => "aaaa") validation.valid?(instance) end expect false do validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :within => 2..4 instance = stub(:username => "aaaaa") validation.valid?(instance) end expect false do validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :within => 2..4 instance = stub(:username => nil) validation.valid?(instance) end expect true do validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :within => 2..4, :allow_nil => true instance = stub(:username => nil) validation.valid?(instance) end expect true do options = [:message, :if, :times, :level, :groups, :maximum, :minimum, :is, :within, :allow_nil] Validatable::ValidatesLengthOf.new(stub_everything, :test).must_understand(options.to_blank_options_hash) end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/vendor/gems/validatable-1.6.7/test/unit/validatable_test.rb
provider/vendor/gems/validatable-1.6.7/test/unit/validatable_test.rb
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') Expectations do expect false do validation = stub_everything(:should_validate? => true, :attribute => "attribute", :level => 1, :groups => []) klass = Class.new do include Validatable validations << validation end klass.new.valid? end expect true do klass = Class.new do include Validatable end instance = klass.new instance.errors.add(:attribute, "message") instance.valid? instance.errors.empty? end expect false do klass = Class.new do include Validatable end klass.validation_keys_include?("anything") end expect true do validation = stub_everything(:key => "key") klass = Class.new do include Validatable validations << validation end klass.validation_keys_include?("key") end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/vendor/gems/validatable-1.6.7/test/unit/validates_numericality_of_test.rb
provider/vendor/gems/validatable-1.6.7/test/unit/validates_numericality_of_test.rb
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') Expectations do expect false do validation = Validatable::ValidatesNumericalityOf.new stub_everything, :nothing instance = stub(:nothing => nil) validation.valid?(instance) end expect true do validation = Validatable::ValidatesNumericalityOf.new stub_everything, :some_int instance = stub(:some_int => 50) validation.valid?(instance) end expect true do validation = Validatable::ValidatesNumericalityOf.new stub_everything, :some_decimal instance = stub(:some_decimal => 1.23) validation.valid?(instance) end expect false do validation = Validatable::ValidatesNumericalityOf.new stub_everything, :some_decimal, :only_integer => true instance = stub(:some_decimal => 1.23) validation.valid?(instance) end expect true do validation = Validatable::ValidatesNumericalityOf.new stub_everything, :some_negative_number, :only_integer => true instance = stub(:some_negative_number => "-1") validation.valid?(instance) end expect false do validation = Validatable::ValidatesNumericalityOf.new stub_everything, :some_non_numeric instance = stub(:some_non_numeric => "50F") validation.valid?(instance) end expect false do validation = Validatable::ValidatesNumericalityOf.new stub_everything, :multiple_dots instance = stub(:multiple_dots => "50.0.0") validation.valid?(instance) end expect true do options = [:message, :if, :times, :level, :groups, :only_integer] Validatable::ValidatesNumericalityOf.new(stub_everything, :test).must_understand(options.to_blank_options_hash) end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/vendor/gems/validatable-1.6.7/test/unit/validates_presence_of_test.rb
provider/vendor/gems/validatable-1.6.7/test/unit/validates_presence_of_test.rb
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') Expectations do expect false do validation = Validatable::ValidatesPresenceOf.new stub_everything, :name validation.valid?(stub_everything) end expect true do validation = Validatable::ValidatesPresenceOf.new stub_everything, :name validation.valid?(stub(:name=>"book")) end expect true do validation = Validatable::ValidatesPresenceOf.new stub_everything, :employee validation.valid?(stub(:employee => stub(:nil? => false))) end expect true do options = {:message => nil, :if => nil, :times => nil, :level => nil, :groups => nil} Validatable::ValidatesPresenceOf.new(stub_everything, :test).must_understand(options) end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/vendor/gems/validatable-1.6.7/test/unit/understandable_test.rb
provider/vendor/gems/validatable-1.6.7/test/unit/understandable_test.rb
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') Expectations do expect [:c, :b, :a] do a = Class.new do include Validatable::Understandable understands :a end b = Class.new(a) do include Validatable::Understandable understands :b end c = Class.new(b) do include Validatable::Understandable understands :c end c.all_understandings end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/vendor/gems/validatable-1.6.7/test/functional/validates_each_test.rb
provider/vendor/gems/validatable-1.6.7/test/functional/validates_each_test.rb
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') functional_tests do expect :is_set do klass = Class.new do include Validatable attr_accessor :name, :result validates_each :name, :logic => lambda { @result = :is_set } end instance = klass.new instance.valid? instance.result end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/vendor/gems/validatable-1.6.7/test/functional/validates_format_of_test.rb
provider/vendor/gems/validatable-1.6.7/test/functional/validates_format_of_test.rb
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') module Functional class ValidatesFormatOfTest < Test::Unit::TestCase test "given invalid name format, when validated, then error is in the objects error collection" do klass = Class.new do include Validatable attr_accessor :name validates_format_of :name, :with => /.+/ end instance = klass.new instance.valid? assert_equal "is invalid", instance.errors.on(:name) end test "given invalid name format and nil name, when validated, then error is in the objects error collection" do klass = Class.new do include Validatable attr_accessor :name validates_format_of :name, :with => /.+/, :if => Proc.new { !name.nil? } end assert_equal true, klass.new.valid? end test "given invalid name format and a name, when validated, then error is in the objects error collection" do klass = Class.new do include Validatable attr_accessor :name validates_format_of :name, :with => /.+/, :if => Proc.new { name.nil? } end assert_equal false, klass.new.valid? end end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/vendor/gems/validatable-1.6.7/test/functional/validates_true_for_test.rb
provider/vendor/gems/validatable-1.6.7/test/functional/validates_true_for_test.rb
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') module Functional class ValidatesFormatOfTest < Test::Unit::TestCase test "given invalid name, when validated, then error is in the objects error collection" do klass = Class.new do include Validatable attr_accessor :name validates_true_for :name, :logic => lambda { name == "nombre" } end instance = klass.new instance.valid? assert_equal "is invalid", instance.errors.on(:name) end test "given valid name, when validated, then no error is in the objects error collection" do klass = Class.new do include Validatable attr_accessor :name validates_true_for :name, :logic => lambda { name == "nombre" } end instance = klass.new instance.name = "nombre" assert_equal true, instance.valid? end end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/vendor/gems/validatable-1.6.7/test/functional/validates_acceptance_of_test.rb
provider/vendor/gems/validatable-1.6.7/test/functional/validates_acceptance_of_test.rb
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') module Functional class ValidatesAcceptanceOfTest < Test::Unit::TestCase test "given no acceptance, when validated, then error is in the objects error collection" do klass = Class.new do include Validatable attr_accessor :name validates_acceptance_of :name end instance = klass.new instance.valid? assert_equal "must be accepted", instance.errors.on(:name) end end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/vendor/gems/validatable-1.6.7/test/functional/validates_confirmation_of_test.rb
provider/vendor/gems/validatable-1.6.7/test/functional/validates_confirmation_of_test.rb
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') module Functional class ValidatesConfirmationOfTest < Test::Unit::TestCase test "given non matching attributes, when validated, then error is in the objects error collection" do klass = Class.new do include Validatable attr_accessor :name, :name_confirmation validates_confirmation_of :name end instance = klass.new instance.name = "foo" instance.name_confirmation = "bar" instance.valid? assert_equal "doesn't match confirmation", instance.errors.on(:name) end test "given matching attributes, when validated, then no error is in the objects error collection" do klass = Class.new do include Validatable attr_accessor :name, :name_confirmation validates_confirmation_of :name end instance = klass.new instance.name = "foo" instance.name_confirmation = "foo" assert_equal true, instance.valid? end test "given matching attributes of different case, when validated with case sensitive false, then no error is in the objects error collection" do klass = Class.new do include Validatable attr_accessor :name, :name_confirmation validates_confirmation_of :name, :case_sensitive => false end instance = klass.new instance.name = "foo" instance.name_confirmation = "FOO" assert_equal true, instance.valid? end test "given matching attributes of different case, when validated with case sensitive true, then error is in the objects error collection" do klass = Class.new do include Validatable attr_accessor :name, :name_confirmation validates_confirmation_of :name end instance = klass.new instance.name = "foo" instance.name_confirmation = "FOO" assert_equal false, instance.valid? assert_equal "doesn't match confirmation", instance.errors.on(:name) end end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/vendor/gems/validatable-1.6.7/test/functional/validates_length_of_test.rb
provider/vendor/gems/validatable-1.6.7/test/functional/validates_length_of_test.rb
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') module Functional class ValidatesLengthOfTest < Test::Unit::TestCase test "given short value, when validated, then error is in the objects error collection" do klass = Class.new do include Validatable attr_accessor :name validates_length_of :name, :minimum => 2 end instance = klass.new instance.valid? assert_equal "is invalid", instance.errors.on(:name) end test "given is constraint, when validated, then error is in the objects error collection" do klass = Class.new do include Validatable attr_accessor :name validates_length_of :name, :is => 2 end instance = klass.new instance.valid? assert_equal "is invalid", instance.errors.on(:name) end test "given is constraint is met, when validated, then valid is true" do klass = Class.new do include Validatable attr_accessor :name validates_length_of :name, :is => 2 end instance = klass.new instance.name = "bk" assert_equal true, instance.valid? end test "given within constraint, when validated, then error is in the objects error collection" do klass = Class.new do include Validatable attr_accessor :name validates_length_of :name, :within => 2..4 end instance = klass.new instance.valid? assert_equal "is invalid", instance.errors.on(:name) end test "given within constraint, when validated, then valid is true" do klass = Class.new do include Validatable attr_accessor :name validates_length_of :name, :within => 2..4 end instance = klass.new instance.name = "bk" assert_equal true, instance.valid? end end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/vendor/gems/validatable-1.6.7/test/functional/validatable_test.rb
provider/vendor/gems/validatable-1.6.7/test/functional/validatable_test.rb
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') functional_tests do expect "can't be empty" do child_class = Module.new do include Validatable validates_presence_of :name end klass = Class.new do include Validatable include_validations_from :child define_method :child do child_class end attr_accessor :name end instance = klass.new instance.valid? instance.errors.on(:name) end expect "can't be empty" do child_class = Module.new do include Validatable validates_presence_of :name end klass = Class.new do include Validatable validates_presence_of :address include_validations_from :child define_method :child do child_class end attr_accessor :name, :address end instance = klass.new instance.valid? instance.errors.on(:address) end expect :is_set do klass = Class.new do include Validatable attr_accessor :result before_validation do self.result = :is_set end end instance = klass.new instance.valid? instance.result end expect :is_set do klass = Class.new do include Validatable attr_accessor :name, :result validates_presence_of :name, :after_validate => lambda { |result, attribute| self.result = :is_set } end instance = klass.new instance.valid? instance.result end expect false do klass = Class.new do include Validatable attr_accessor :name validates_presence_of :name end subclass = Class.new klass do end subsubclass = Class.new subclass do end subsubclass.new.valid? end expect false do klass = Class.new do include Validatable attr_accessor :name validates_presence_of :name end subclass = Class.new klass do end subclass.new.valid? end expect true do klass = Class.new do include Validatable attr_accessor :name validates_presence_of :name end subclass = Class.new klass do end instance = subclass.new instance.name = 'a name' instance.valid? end expect ArgumentError do Class.new do include Validatable attr_accessor :name validates_presence_of :name, :times => 1 validates_presence_of :name, :times => 1 end end expect ArgumentError do Class.new do include Validatable attr_accessor :name validates_presence_of :name, :times => 1, :key => 'anything' validates_presence_of :name, :times => 1, :key => 'anything' end end expect "is invalid" do child_class = Class.new do include Validatable attr_accessor :name, :address validates_presence_of :name validates_format_of :address, :with => /.+/ end klass = Class.new do include Validatable include_errors_from :child define_method :child do child_class.new end end instance = klass.new instance.valid? instance.errors.on(:address) end expect "can't be empty" do child_class = Class.new do include Validatable attr_accessor :name, :address validates_presence_of :name validates_format_of :address, :with => /.+/ end klass = Class.new do include Validatable include_errors_from :child define_method :child do child_class.new end end instance = klass.new instance.valid? instance.errors.on(:name) end test "when child validations have errors, level 2 and higher parent validations are not performed" do child_class = Class.new do include Validatable attr_accessor :name validates_presence_of :name end klass = Class.new do include Validatable extend Forwardable def_delegator :child, :name validates_true_for :name, :logic => lambda { false }, :level => 2, :message => "invalid message" include_errors_from :child define_method :child do @child ||= child_class.new end end instance = klass.new instance.valid? assert_equal "can't be empty", instance.errors.on(:name) end test "when child validations have errors, level 1 parent validations are still performed" do child_class = Class.new do include Validatable attr_accessor :name validates_presence_of :name end klass = Class.new do include Validatable validates_true_for :address, :logic => lambda { false }, :level => 1, :message => "invalid message" include_errors_from :child define_method :child do @child ||= child_class.new end end instance = klass.new instance.valid? assert_equal "can't be empty", instance.errors.on(:name) assert_equal "invalid message", instance.errors.on(:address) end expect "can't be empty" do child_class = Class.new do include Validatable attr_accessor :name, :address validates_presence_of :name end klass = Class.new do include Validatable include_errors_from :child, :map => {:name => :namen} define_method :child do child_class.new end end instance = klass.new instance.valid? instance.errors.on(:namen) end expect "can't be empty" do child_class = Class.new do include Validatable attr_accessor :name, :address validates_presence_of :name end klass = Class.new do include Validatable include_errors_from :child, :if => lambda { true } define_method :child do child_class.new end end instance = klass.new instance.valid? instance.errors.on(:name) end expect true do child_class = Class.new do include Validatable attr_accessor :name, :address validates_presence_of :name end klass = Class.new do include Validatable include_errors_from :child, :if => lambda { false } define_method :child do child_class.new end end instance = klass.new instance.valid? end test "classes only have valid_for_* methods for groups that appear in their validations" do class_with_group_one = Class.new do include Validatable validates_presence_of :name, :groups => :group_one attr_accessor :name end class_with_group_two = Class.new do include Validatable validates_presence_of :name, :groups => :group_two attr_accessor :name end assert_equal false, class_with_group_one.public_instance_methods.include?(:valid_for_group_two?) assert_equal false, class_with_group_two.public_instance_methods.include?(:valid_for_group_one?) end test "nonmatching groups are not used as validations" do klass = Class.new do include Validatable validates_presence_of :name, :groups => :group_one validates_presence_of :address, :groups => :group_two attr_accessor :name, :address end instance = klass.new assert_equal nil, instance.errors.on(:name) end expect "can't be empty twice changed message" do klass = Class.new do include Validatable validates_presence_of :name attr_accessor :name end Validatable::ValidationBase.class_eval do after_validate do |result, instance, attribute| instance.errors.add(attribute, " changed message") end end Validatable::ValidatesPresenceOf.class_eval do after_validate do |result, instance, attribute| instance.errors.add(attribute, " twice") end end instance = klass.new instance.valid? Validatable::ValidatesPresenceOf.after_validations.clear Validatable::ValidationBase.after_validations.clear instance.errors.on(:name).join end expect false do klass = Class.new do include Validatable validates_presence_of :name, :groups => :group_one attr_accessor :name end instance = klass.new instance.valid_for_group_one? end expect false do klass = Class.new do include Validatable validates_presence_of :name, :groups => [:group_one, :group_two] attr_accessor :name end instance = klass.new instance.valid_for_group_one? end expect true do klass = Class.new do include Validatable validates_presence_of :name, :groups => :group_one validates_presence_of :address attr_accessor :name, :address end instance = klass.new instance.address = 'anything' instance.valid? end expect true do klass = Class.new do include Validatable validates_presence_of :name, :groups => :group_one attr_accessor :name end instance = klass.new instance.valid? end expect true do klass = Class.new do include Validatable validates_presence_of :name, :times => 1 attr_accessor :name end instance = klass.new instance.valid? instance.valid? end expect false do klass = Class.new do include Validatable validates_presence_of :name, :times => 1 attr_accessor :name end instance1 = klass.new instance1.valid? instance2 = klass.new instance2.valid? end expect "name message" do klass = Class.new do include Validatable validates_presence_of :name, :level => 1, :message => "name message" validates_presence_of :address, :level => 2 attr_accessor :name, :address end instance = klass.new instance.valid? instance.errors.on(:name) end expect nil do klass = Class.new do include Validatable validates_presence_of :name, :level => 1, :message => "name message" validates_presence_of :address, :level => 2 attr_accessor :name, :address end instance = klass.new instance.valid? instance.errors.on(:address) end expect "Mod::Klass/Validatable::ValidatesPresenceOf/name" do module Mod class Klass include Validatable validates_presence_of :name end end Mod::Klass.validations.first.key end expect "/Validatable::ValidatesPresenceOf/custom key" do klass = Class.new do include Validatable validates_presence_of :name, :key => "custom key" end klass.validations.first.key end expect "can't be empty" do klass = Class.new do include Validatable validates_presence_of :name, :address attr_accessor :name, :address end instance = klass.new instance.validate_only("presence_of/name") instance.errors.on(:name) end expect nil do klass = Class.new do include Validatable validates_presence_of :name, :address attr_accessor :name, :address end instance = klass.new instance.validate_only("presence_of/name") instance.errors.on(:address) end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/vendor/gems/validatable-1.6.7/test/functional/validates_numericality_of_test.rb
provider/vendor/gems/validatable-1.6.7/test/functional/validates_numericality_of_test.rb
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') module Functional class ValidatesNumericalityOfTest < Test::Unit::TestCase test "when validating numericality and the value is nil an error should exist on the instance" do klass = Class.new do include Validatable attr_accessor :nothing validates_numericality_of :nothing end instance = klass.new instance.valid? assert_equal "must be a number", instance.errors.on(:nothing) end test "when validating numericality and the value has a non numeric character an error should exist on the instance" do klass = Class.new do include Validatable validates_numericality_of :some_string def some_string "some_string" end end instance = klass.new instance.valid? assert_equal "must be a number", instance.errors.on(:some_string) end test "when validating a number no error will be in the instance" do klass = Class.new do include Validatable validates_numericality_of :valid_number def valid_number 1.23 end end instance = klass.new instance.valid? assert_equal nil, instance.errors.on(:valid_number) end test "when validating an integer and the value is a decimal an error should exist on the instance" do klass = Class.new do include Validatable validates_numericality_of :valid_number, :only_integer => true attr_accessor :valid_number end instance = klass.new instance.valid_number = 1.23 instance.valid? assert_equal "must be a number", instance.errors.on(:valid_number) end end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/vendor/gems/validatable-1.6.7/test/functional/validates_presence_of_test.rb
provider/vendor/gems/validatable-1.6.7/test/functional/validates_presence_of_test.rb
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') module Functional class ValidatesPresenceOfTest < Test::Unit::TestCase test "given no name, when validated, then error is in the objects error collection" do klass = Class.new do include Validatable attr_accessor :name validates_presence_of :name end instance = klass.new instance.valid? assert_equal "can't be empty", instance.errors.on(:name) end end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/vendor/gems/validatable-1.6.7/lib/macros.rb
provider/vendor/gems/validatable-1.6.7/lib/macros.rb
module Validatable module Macros # call-seq: validates_each(*args) # # Validates that the logic evaluates to true # # class Address # include Validatable # validates_each :zip_code, :logic => lambda { errors.add(:zip_code, "is not valid") if ZipCodeService.allows(zip_code) } # end # # The logic option is required. # # Configuration options: # # * after_validate - A block that executes following the run of a validation # * group - The group that this validation belongs to. A validation can belong to multiple groups # * if - A block that when executed must return true of the validation will not occur # * level - The level at which the validation should occur # * logic - A block that executes to perform the validation # * message - The message to add to the errors collection when the validation fails # * times - The number of times the validation applies def validates_each(*args) add_validations(args, ValidatesEach) end # call-seq: validates_format_of(*args) # # Validates whether the value of the specified attribute is of the # correct form by matching it against the regular expression provided. # # class Person # include Validatable # validates_format_of :first_name, :with => /[ A-Za-z]/ # end # # A regular expression must be provided or else an exception will be raised. # # Configuration options: # # * after_validate - A block that executes following the run of a validation # * message - The message to add to the errors collection when the validation fails # * times - The number of times the validation applies # * level - The level at which the validation should occur # * if - A block that when executed must return true of the validation will not occur # * with - The regular expression used to validate the format # * group - The group that this validation belongs to. A validation can belong to multiple groups def validates_format_of(*args) add_validations(args, ValidatesFormatOf) end # call-seq: validates_length_of(*args) # # Validates that the specified attribute matches the length restrictions supplied. # # class Person # include Validatable # validates_length_of :first_name, :maximum=>30 # validates_length_of :last_name, :minimum=>30 # end # # Configuration options: # # * after_validate - A block that executes following the run of a validation # * message - The message to add to the errors collection when the validation fails # * times - The number of times the validation applies # * level - The level at which the validation should occur # * if - A block that when executed must return true of the validation will not occur # * minimum - The minimum size of the attribute # * maximum - The maximum size of the attribute # * is - The size the attribute must be # * within - A range that the size of the attribute must fall within # * group - The group that this validation belongs to. A validation can belong to multiple groups def validates_length_of(*args) add_validations(args, ValidatesLengthOf) end # call-seq: validates_numericality_of(*args) # # Validates that the specified attribute is numeric. # # class Person # include Validatable # validates_numericality_of :age # end # # Configuration options: # # * after_validate - A block that executes following the run of a validation # * message - The message to add to the errors collection when the validation fails # * times - The number of times the validation applies # * level - The level at which the validation should occur # * if - A block that when executed must return true of the validation will not occur # * group - The group that this validation belongs to. A validation can belong to multiple groups # * only_integer - Whether the attribute must be an integer (default is false) def validates_numericality_of(*args) add_validations(args, ValidatesNumericalityOf) end # call-seq: validates_acceptance_of(*args) # # Encapsulates the pattern of wanting to validate the acceptance of a terms of service check box (or similar agreement). Example: # # class Person # include Validatable # validates_acceptance_of :terms_of_service # validates_acceptance_of :eula, :message => "must be abided" # end # # Configuration options: # # * after_validate - A block that executes following the run of a validation # * message - The message to add to the errors collection when the validation fails # * times - The number of times the validation applies # * level - The level at which the validation should occur # * if - A block that when executed must return true of the validation will not occur # * group - The group that this validation belongs to. A validation can belong to multiple groups def validates_acceptance_of(*args) add_validations(args, ValidatesAcceptanceOf) end # call-seq: validates_confirmation_of(*args) # # Encapsulates the pattern of wanting to validate a password or email address field with a confirmation. Example: # # Class: # class PersonPresenter # include Validatable # validates_confirmation_of :user_name, :password # validates_confirmation_of :email_address, :message => "should match confirmation" # end # # View: # <%= password_field "person", "password" %> # <%= password_field "person", "password_confirmation" %> # # Configuration options: # # * after_validate - A block that executes following the run of a validation # * case_sensitive - Whether or not to apply case-sensitivity on the comparison. Defaults to true. # * message - The message to add to the errors collection when the validation fails # * times - The number of times the validation applies # * level - The level at which the validation should occur # * if - A block that when executed must return true of the validation will not occur # * group - The group that this validation belongs to. A validation can belong to multiple groups def validates_confirmation_of(*args) add_validations(args, ValidatesConfirmationOf) end # call-seq: validates_presence_of(*args) # # Validates that the specified attributes are not nil or an empty string # # class Person # include Validatable # validates_presence_of :first_name # end # # The first_name attribute must be in the object and it cannot be nil or empty. # # Configuration options: # # * after_validate - A block that executes following the run of a validation # * message - The message to add to the errors collection when the validation fails # * times - The number of times the validation applies # * level - The level at which the validation should occur # * if - A block that when executed must return true of the validation will not occur # * group - The group that this validation belongs to. A validation can belong to multiple groups def validates_presence_of(*args) add_validations(args, ValidatesPresenceOf) end # call-seq: validates_true_for(*args) # # Validates that the logic evaluates to true # # class Person # include Validatable # validates_true_for :first_name, :logic => lambda { first_name == 'Jamie' } # end # # The logic option is required. # # Configuration options: # # * after_validate - A block that executes following the run of a validation # * message - The message to add to the errors collection when the validation fails # * times - The number of times the validation applies # * level - The level at which the validation should occur # * if - A block that when executed must return true of the validation will not occur # * group - The group that this validation belongs to. A validation can belong to multiple groups # * logic - A block that executes to perform the validation def validates_true_for(*args) add_validations(args, ValidatesTrueFor) end # call-seq: include_validations_from(attribute) # # Includes all the validations that are defined on the attribute. # class Person # include Validatable # validates_presence_of :name # end # # class PersonPresenter # include Validatable # include_validataions_from :person # attr_accessor :person # def name # person.name # end # # def initialize(person) # @person = person # end # end # # presenter = PersonPresenter.new(Person.new) # presenter.valid? #=> false # presenter.errors.on(:name) #=> "can't be blank" # # The name attribute whose validations should be added. def include_validations_from(attribute_to_validate, options = {}) validations_to_include << IncludedValidation.new(attribute_to_validate) end # call-seq: include_errors_from(attribute_to_validate, options = {}) # # Validates the specified attributes. # class Person # include Validatable # validates_presence_of :name # attr_accessor :name # end # # class PersonPresenter # include Validatable # include_errors_from :person, :map => { :name => :namen }, :if => lambda { not person.nil? } # attr_accessor :person # # def initialize(person) # @person = person # end # end # # presenter = PersonPresenter.new(Person.new) # presenter.valid? #=> false # presenter.errors.on(:namen) #=> "can't be blank" # # The person attribute will be validated. # If person is invalid the errors will be added to the PersonPresenter errors collection. # # Configuration options: # # * map - A hash that maps attributes of the child to attributes of the parent. # * if - A block that when executed must return true of the validation will not occur. def include_errors_from(attribute_to_validate, options = {}) children_to_validate << ChildValidation.new(attribute_to_validate, options[:map] || {}, options[:if] || lambda { true }) end def include_validations_for(attribute_to_validate, options = {}) #:nodoc: puts "include_validations_for is deprecated; use include_errors_from instead" children_to_validate << ChildValidation.new(attribute_to_validate, options[:map] || {}, options[:if] || lambda { true }) end # call-seq: before_validation(&block) # # Is called before valid? or valid_for_*? # # class Person # include Validatable # before_validation do # self.name = "default name" # end # # attr_accessor :name # end # def before_validation(&block) before_validations << block end end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/vendor/gems/validatable-1.6.7/lib/included_validation.rb
provider/vendor/gems/validatable-1.6.7/lib/included_validation.rb
module Validatable class IncludedValidation #:nodoc: attr_accessor :attribute def initialize(attribute) @attribute = attribute end end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/vendor/gems/validatable-1.6.7/lib/object_extension.rb
provider/vendor/gems/validatable-1.6.7/lib/object_extension.rb
class Object #:nodoc: module InstanceExecHelper #:nodoc: end include InstanceExecHelper def instance_eval_with_params(*args, &block) begin old_critical, Thread.critical = Thread.critical, true n = 0 n += 1 while respond_to?(mname="__instance_exec#{n}") InstanceExecHelper.module_eval{ define_method(mname, &block) } ensure Thread.critical = old_critical end begin ret = send(mname, *args) ensure InstanceExecHelper.module_eval{ remove_method(mname) } rescue nil end ret end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/vendor/gems/validatable-1.6.7/lib/errors.rb
provider/vendor/gems/validatable-1.6.7/lib/errors.rb
module Validatable class Errors extend Forwardable include Enumerable def_delegators :errors, :clear, :each, :each_pair, :empty?, :length, :size # call-seq: on(attribute) # # * Returns nil, if no errors are associated with the specified +attribute+. # * Returns the error message, if one error is associated with the specified +attribute+. # * Returns an array of error messages, if more than one error is associated with the specified +attribute+. def on(attribute) return nil if errors[attribute.to_sym].nil? errors[attribute.to_sym].size == 1 ? errors[attribute.to_sym].first : errors[attribute.to_sym] end def add(attribute, message) #:nodoc: errors[attribute.to_sym] = [] if errors[attribute.to_sym].nil? errors[attribute.to_sym] << message end def merge!(errors) #:nodoc: errors.each_pair{|k, v| add(k,v)} self end # call-seq: replace(attribute) # # * Replaces the errors value for the given +attribute+ def replace(attribute, value) errors[attribute.to_sym] = value end # call-seq: raw(attribute) # # * Returns an array of error messages associated with the specified +attribute+. def raw(attribute) errors[attribute.to_sym] end def errors #:nodoc: @errors ||= {} end def count #:nodoc: errors.values.flatten.size end # call-seq: full_messages -> an_array_of_messages # # Returns an array containing the full list of error messages. def full_messages full_messages = [] errors.each_key do |attribute| errors[attribute].each do |msg| next if msg.nil? if attribute.to_s == "base" full_messages << msg else full_messages << humanize(attribute.to_s) + " " + msg end end end full_messages end def humanize(lower_case_and_underscored_word) #:nodoc: lower_case_and_underscored_word.to_s.gsub(/_id$/, "").gsub(/_/, " ").capitalize end end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/vendor/gems/validatable-1.6.7/lib/validatable_instance_methods.rb
provider/vendor/gems/validatable-1.6.7/lib/validatable_instance_methods.rb
module Validatable def self.included(klass) #:nodoc: klass.extend Validatable::ClassMethods klass.extend Validatable::Macros end # call-seq: valid? # # Returns true if no errors were added otherwise false. Only executes validations that have no :groups option specified def valid? valid_for_group?(nil) end # call-seq: errors # # Returns the Errors object that holds all information about attribute error messages. def errors @errors ||= Validatable::Errors.new end def valid_for_group?(group) #:nodoc: run_before_validations errors.clear self.class.validate_children(self, group) self.validate(group) errors.empty? end def times_validated(key) #:nodoc: times_validated_hash[key] || 0 end def increment_times_validated_for(validation) #:nodoc: if validation.key != nil if times_validated_hash[validation.key].nil? times_validated_hash[validation.key] = 1 else times_validated_hash[validation.key] += 1 end end end # call-seq: validate_only(key) # # Only executes a specified validation. The argument should follow a pattern based on the key of the validation. # Examples: # * validates_presence_of :name can be run with obj.validate_only("presence_of/name") # * validates_presence_of :birthday, :key => "a key" can be run with obj.validate_only("presence_of/a key") def validate_only(key) validation_name, attribute_name = key.split("/") validation_name = validation_name.split("_").collect{|word| word.capitalize}.join validation_key = "#{self.class.name}/Validatable::Validates#{validation_name}/#{attribute_name}" validation = self.class.all_validations.find { |validation| validation.key == validation_key } raise ArgumentError.new("validation with key #{validation_key} could not be found") if validation.nil? errors.clear run_validation(validation) end protected def times_validated_hash #:nodoc: @times_validated_hash ||= {} end def validate(group) #:nodoc: validation_levels.each do |level| validations_for_level_and_group(level, group).each do |validation| run_validation(validation) if validation.should_validate?(self) end return unless self.errors.empty? end end def run_validation(validation) #:nodoc: validation_result = validation.valid?(self) add_error(validation.attribute, validation.message(self)) unless validation_result increment_times_validated_for(validation) validation.run_after_validate(validation_result, self, validation.attribute) end def run_before_validations #:nodoc: self.class.all_before_validations.each do |block| instance_eval &block end end def add_error(attribute, message) #:nodoc: self.class.add_error(self, attribute, message) end def validations_for_level_and_group(level, group) #:nodoc: validations_for_level = self.all_validations.select { |validation| validation.level == level } return validations_for_level.select { |validation| validation.groups.empty? } if group.nil? validations_for_level.select { |validation| validation.groups.include?(group) } end def all_validations #:nodoc: res = self.class.validations_to_include.inject(self.class.all_validations) do |result, included_validation_class| result += self.send(included_validation_class.attribute).all_validations result end end def validation_levels #:nodoc: self.class.all_validations.inject([1]) { |result, validation| result << validation.level }.uniq.sort end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/vendor/gems/validatable-1.6.7/lib/validatable.rb
provider/vendor/gems/validatable-1.6.7/lib/validatable.rb
require 'forwardable' require File.expand_path(File.dirname(__FILE__) + '/object_extension') require File.expand_path(File.dirname(__FILE__) + '/errors') require File.expand_path(File.dirname(__FILE__) + '/validatable_class_methods') require File.expand_path(File.dirname(__FILE__) + '/macros') require File.expand_path(File.dirname(__FILE__) + '/validatable_instance_methods') require File.expand_path(File.dirname(__FILE__) + '/included_validation') require File.expand_path(File.dirname(__FILE__) + '/child_validation') require File.expand_path(File.dirname(__FILE__) + '/understandable') require File.expand_path(File.dirname(__FILE__) + '/requireable') require File.expand_path(File.dirname(__FILE__) + '/validations/validation_base') require File.expand_path(File.dirname(__FILE__) + '/validations/validates_format_of') require File.expand_path(File.dirname(__FILE__) + '/validations/validates_presence_of') require File.expand_path(File.dirname(__FILE__) + '/validations/validates_acceptance_of') require File.expand_path(File.dirname(__FILE__) + '/validations/validates_confirmation_of') require File.expand_path(File.dirname(__FILE__) + '/validations/validates_length_of') require File.expand_path(File.dirname(__FILE__) + '/validations/validates_true_for') require File.expand_path(File.dirname(__FILE__) + '/validations/validates_numericality_of') require File.expand_path(File.dirname(__FILE__) + '/validations/validates_each')
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false
ThoughtWorksStudios/oauth2_provider
https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/provider/vendor/gems/validatable-1.6.7/lib/understandable.rb
provider/vendor/gems/validatable-1.6.7/lib/understandable.rb
module Validatable module Understandable #:nodoc: module ClassMethods #:nodoc: def understands(*args) understandings.concat args end def understandings @understandings ||= [] end def all_understandings return understandings + self.superclass.all_understandings if self.superclass.respond_to? :all_understandings understandings end end def self.included(klass) klass.extend ClassMethods end def must_understand(hash) invalid_options = hash.inject([]) do |errors, (key, value)| errors << key.to_s unless self.class.all_understandings.include?(key) errors end raise ArgumentError.new("invalid options: #{invalid_options.join(', ')}") if invalid_options.any? true end end end
ruby
MIT
d54702f194edd05389968cf8947465860abccc5d
2026-01-04T17:46:04.645080Z
false