[#23457] [Bug #1471] "Mutual join" deadlock detection faulty in 1.8.6 and 1.8.7 — John Carter <redmine@...>

Bug #1471: "Mutual join" deadlock detection faulty in 1.8.6 and 1.8.7

17 messages 2009/05/15

[#23483] [Bug #1478] Ruby archive — Oleg Puchinin <redmine@...>

Bug #1478: Ruby archive

29 messages 2009/05/16
[#29225] [Feature #1478] Ruby archive — Luis Lavena <redmine@...> 2010/04/02

Issue #1478 has been updated by Luis Lavena.

[#30345] Re: [Feature #1478] Ruby archive — "NAKAMURA, Hiroshi" <nakahiro@...> 2010/05/21

On Fri, Apr 2, 2010 at 17:13, Luis Lavena <redmine@ruby-lang.org> wrote:

[#30346] Re: [Feature #1478] Ruby archive — Jonathan Nielsen <jonathan@...> 2010/05/21

> Thanks for your comment.

[#30347] Re: [Feature #1478] Ruby archive — Jonathan Nielsen <jonathan@...> 2010/05/21

OK Hiroshi, I read some of the comments earlier in the thread that I

[#30355] Re: [Feature #1478] Ruby archive — Caleb Clausen <vikkous@...> 2010/05/21

On 5/20/10, Jonathan Nielsen <jonathan@jmnet.us> wrote:

[#30364] Re: [Feature #1478] Ruby archive — Benoit Daloze <eregontp@...> 2010/05/22

Hi,

[#23505] [Bug #1494] tempfile#unlink may silently fail on windows — Nicholas Manning <redmine@...>

Bug #1494: tempfile#unlink may silently fail on windows

19 messages 2009/05/19

[#23572] [Bug #1525] Deadlock in Ruby 1.9's VM caused by ConditionVariable.wait and fork? — Hongli Lai <redmine@...>

Bug #1525: Deadlock in Ruby 1.9's VM caused by ConditionVariable.wait and fork?

27 messages 2009/05/27

[#23595] Meaning of RUBY_PLATFORM — Rick DeNatale <rick.denatale@...>

The RUBY_PLATFORM constant is documented in the latest Pickaxe as "The

17 messages 2009/05/28
[#23596] Re: Meaning of RUBY_PLATFORM — Luis Lavena <luislavena@...> 2009/05/28

On Thu, May 28, 2009 at 3:41 PM, Rick DeNatale <rick.denatale@gmail.com> wrote:

[#23602] Re: Meaning of RUBY_PLATFORM — Rick DeNatale <rick.denatale@...> 2009/05/28

On Thu, May 28, 2009 at 2:52 PM, Luis Lavena <luislavena@gmail.com> wrote:

[#23608] Re: Meaning of RUBY_PLATFORM — Luis Lavena <luislavena@...> 2009/05/28

On Thu, May 28, 2009 at 7:08 PM, Rick DeNatale <rick.denatale@gmail.com> wrote:

[#23609] Re: Meaning of RUBY_PLATFORM — Rick DeNatale <rick.denatale@...> 2009/05/29

On Thu, May 28, 2009 at 7:22 PM, Luis Lavena <luislavena@gmail.com> wrote:

[ruby-core:23361] [Feature #1436] Please consider this addition to resolv.rb which adds methods for resolving LOC resources

From: JB Smith <redmine@...>
Date: 2009-05-05 23:49:06 UTC
List: ruby-core #23361
Feature #1436: Please consider this addition to resolv.rb which adds methods for resolving LOC resources
http://redmine.ruby-lang.org/issues/show/1436

Author: JB Smith
Status: Open, Priority: Normal
Category: core

Please consider this diff which would add support to resolv.rb to permit parsing of LOC resources.
I would welcome any criticism or guidance that would make this more suitable for inclusion.
Regards,

JB Smith




Index: lib/resolv.rb
===================================================================
--- lib/resolv.rb	(revision 23349)
+++ lib/resolv.rb	(working copy)
@@ -1835,6 +1835,97 @@
       end
 
       ##
+      # Location resource
+      
+      class LOC < Resource
+      
+        TypeValue = 29 # :nodoc:
+        
+        def initialize(version, ssize, hprecision, vprecision, latitude, longitude, altitude)
+          @version    = version
+          @ssize      = Resolv::LOC::Size.create(ssize)
+          @hprecision = Resolv::LOC::Size.create(hprecision)
+          @vprecision = Resolv::LOC::Size.create(vprecision)
+          @latitude   = Resolv::LOC::Coord.create(latitude)
+          @longitude  = Resolv::LOC::Coord.create(longitude)
+          @altitude   = Resolv::LOC::Alt.create(altitude)
+        end
+        
+        ##
+        # Returns the version value for this LOC record which should always be 00
+        
+        attr_reader :version
+        
+        ##
+        # The spherical size of this LOC
+        # in meters using scientific notation as 2 integers of XeY
+        
+        attr_reader :ssize
+        
+        ##
+        # The horizontal precision using ssize type values
+        # in meters using scientific notation as 2 integers of XeY
+        # for precision use value/2 e.g. 2m = +/-1m
+        
+        attr_reader :hprecision
+        
+        ##
+        # The vertical precision using ssize type values
+        # in meters using scientific notation as 2 integers of XeY
+        # for precision use value/2 e.g. 2m = +/-1m
+        
+        attr_reader :vprecision
+        
+        ##
+        # The latitude for this LOC where 2**31 is the equator
+        # in thousandths of an arc second as an unsigned 32bit integer
+        
+        attr_reader :latitude
+        
+        ##
+        # The longitude for this LOC where 2**31 is the prime meridian
+        # in thousandths of an arc second as an unsigned 32bit integer
+        
+        attr_reader :longitude
+        
+        ##
+        # The altitude of the LOC above a reference sphere whose surface sits 100km below the WGS84 spheroid
+        # in centimeters as an unsigned 32bit integer
+        
+        attr_reader :altitude
+        
+        
+        def encode_rdata(msg) # :nodoc:
+          msg.put_bytes(@version)
+          msg.put_bytes(@ssize.scalar)
+          msg.put_bytes(@hprecision.scalar)
+          msg.put_bytes(@vprecision.scalar)
+          msg.put_bytes(@latitude.coordinates)
+          msg.put_bytes(@longitude.coordinates)
+          msg.put_bytes(@altitude.altitude)
+        end
+        
+        def self.decode_rdata(msg) # :nodoc:
+          version    = msg.get_bytes(1)
+          ssize      = msg.get_bytes(1)
+          hprecision = msg.get_bytes(1)
+          vprecision = msg.get_bytes(1)
+          latitude   = msg.get_bytes(4)
+          longitude  = msg.get_bytes(4)
+          altitude   = msg.get_bytes(4)
+          return self.new(
+            version, 
+            Resolv::LOC::Size.new(ssize), 
+            Resolv::LOC::Size.new(hprecision), 
+            Resolv::LOC::Size.new(vprecision), 
+            Resolv::LOC::Coord.new(latitude,"lat"), 
+            Resolv::LOC::Coord.new(longitude,"lon"), 
+            Resolv::LOC::Alt.new(altitude)
+          )
+        end
+      end
+
+      ##
       # A Query type requesting any RR.
 
       class ANY < Query
@@ -1842,7 +1933,7 @@
       end
 
       ClassInsensitiveTypes = [ # :nodoc:
-        NS, CNAME, SOA, PTR, HINFO, MINFO, MX, TXT, ANY
+        NS, CNAME, SOA, PTR, HINFO, MINFO, MX, TXT, LOC, ANY
       ]
 
       ##
@@ -2260,6 +2351,223 @@
     end
   end
 
+  module LOC
+  
+    ##
+    # A Resolv::LOC::Size
+    
+    class Size
+    
+      Regex = /^(\d+\.*\d*)[m]$/
+      
+      ##
+      # Creates a new LOC::Size from +arg+ which may be:
+      #
+      # LOC::Size:: returns +arg+.
+      # String:: +arg+ must match the LOC::Size::Regex constant
+      
+      def self.create(arg)
+        case arg
+        when Size
+          return arg
+        when String
+          scalar = ''
+          if Regex =~ arg
+            scalar = [(($1.to_f*(1e2)).to_i.to_s[0].to_i*(2**4)+(($1.to_f*(1e2)).to_i.to_s.length-1))].pack("C")
+          else
+            raise ArgumentError.new("not a properly formed Size string: " + arg)
+          end
+          return Size.new(scalar) 
+        else
+          raise ArgumentError.new("cannot interpret as Size: #{arg.inspect}")
+        end
+      end
+      
+      def initialize(scalar)
+        @scalar = scalar
+      end
+      
+      ##
+      # The raw size
+      
+      attr_reader :scalar
+      
+      def to_s # :nodoc:
+        s = @scalar.unpack("H2").join.to_s
+        return ((s[0].to_i)*(10**(s[1].to_i-2))).to_s << "m"
+      end
+      
+      def inspect # :nodoc:
+        return "#<#{self.class} #{self.to_s}>"
+      end
+      
+      def ==(other) # :nodoc:
+        return @scalar == other.scalar
+      end
+  
+      def eql?(other) # :nodoc:
+        return self == other
+      end
+  
+      def hash # :nodoc:
+        return @scalar.hash
+      end
+      
+    end
+    
+    ##
+    # A Resolv::LOC::Coord
+    
+    class Coord
+    
+      Regex = /^(\d+)\s(\d+)\s(\d+\.\d+)\s([NESW])$/
+      
+      ##
+      # Creates a new LOC::Coord from +arg+ which may be:
+      #
+      # LOC::Coord:: returns +arg+.
+      # String:: +arg+ must match the LOC::Coord::Regex constant
+      
+      def self.create(arg)
+        case arg
+        when Coord
+          return arg
+        when String
+          coordinates = ''
+          if Regex =~ arg &&  $1<180
+            hemi = ($4[/([NE])/,1]) || ($4[/([SW])/,1]) ? 1 : -1
+            coordinates = [(($1.to_i*(36e5))+($2.to_i*(6e4))+($3.to_f*(1e3)))*hemi+(2**31)].pack("N")
+            (orientation ||= '') << $4[[/NS/],1] ? 'lat' : 'lon'
+          else
+            raise ArgumentError.new("not a properly formed Coord string: " + arg)
+          end
+          return Coord.new(coordinates,orientation) 
+        else
+          raise ArgumentError.new("cannot interpret as Coord: #{arg.inspect}")
+        end
+      end
+          
+      def initialize(coordinates,orientation)
+        unless coordinates.kind_of?(String)
+          raise ArgumentError.new("Coord must be a 32bit unsigned integer in hex format: #{coordinates.inspect}")
+        end
+        unless orientation.kind_of?(String) && orientation[/^lon$|^lat$/] 
+          raise ArgumentError.new('Coord expects orientation to be a String argument of "lat" or "lon"')
+        end  
+        @coordinates = coordinates
+        @orientation = orientation
+      end
+  
+      ##
+      # The raw coordinates
+  
+      attr_reader :coordinates
+      
+      ## The orientation of the hemisphere as 'lat' or 'lon'
+      
+      attr_reader :orientation
+      
+      def to_s # :nodoc:
+          c = @coordinates.unpack("N").join.to_i
+          val      = (c - (2**31)).abs
+          fracsecs = (val % 1e3).to_i.to_s 
+          val      = val / 1e3
+          secs     = (val % 60).to_i.to_s 
+          val      = val / 60
+          mins     = (val % 60).to_i.to_s 
+          degs     = (val / 60).to_i.to_s
+          posi = (c >= 2**31)
+          case posi
+          when true
+            hemi = @orientation[/^lat$/] ? "N" : "E"
+          else
+            hemi = @orientation[/^lon$/] ? "W" : "S"
+          end
+          return degs << " " << mins << " " << secs << "." << fracsecs << " " << hemi
+      end
+      
+      def inspect # :nodoc:
+        return "#<#{self.class} #{self.to_s}>"
+      end
+      
+      def ==(other) # :nodoc:
+        return @coordinates == other.coordinates
+      end
+  
+      def eql?(other) # :nodoc:
+        return self == other
+      end
+  
+      def hash # :nodoc:
+        return @coordinates.hash
+      end
+      
+    end
+    
+    ##
+    # A Resolv::LOC::Alt
+    
+    class Alt
+      
+      Regex = /^([+-]*\d+\.*\d*)[m]$/
+      
+      ##
+      # Creates a new LOC::Alt from +arg+ which may be:
+      #
+      # LOC::Alt:: returns +arg+.
+      # String:: +arg+ must match the LOC::Alt::Regex constant
+      
+      def self.create(arg)
+        case arg
+        when Alt
+          return arg
+        when String
+          altitude = ''
+          if Regex =~ arg
+            altitude = [($1.to_f*(1e2))+(1e7)].pack("N")
+          else
+            raise ArgumentError.new("not a properly formed Alt string: " + arg)
+          end
+          return Alt.new(altitude) 
+        else
+          raise ArgumentError.new("cannot interpret as Alt: #{arg.inspect}")
+        end
+      end
+      
+      def initialize(altitude)
+        @altitude = altitude
+      end
+      
+      ##
+      # The raw altitude
+      
+      attr_reader :altitude
+      
+      def to_s # :nodoc:
+        a = @altitude.unpack("N").join.to_i
+        return ((a.to_f/1e2)-1e5).to_s + "m"
+      end
+      
+      def inspect # :nodoc:
+        return "#<#{self.class} #{self.to_s}>"
+      end
+      
+      def ==(other) # :nodoc:
+        return @altitude == other.altitude
+      end
+  
+      def eql?(other) # :nodoc:
+        return self == other
+      end
+  
+      def hash # :nodoc:
+        return @altitude.hash
+      end
+      
+    end
+  
+  end
+
   ##
   # Default resolver to use for Resolv class methods.


----------------------------------------
http://redmine.ruby-lang.org

In This Thread

Prev Next