syspy 0.0.20 → 0.0.21

Sign up to get free protection for your applications and to get access to all the features.
data/bin/syspy CHANGED
@@ -40,6 +40,8 @@ module Syspy
40
40
  replaced_statement.gsub!(match,param.to_s)
41
41
  elsif(param.instance_of?(Time))
42
42
  replaced_statement.gsub!(match,"\"#{param.strftime("%Y%m%d %H:%M:%S")}\"")
43
+ else
44
+ Log.warn(Non replacable parameter: #{match}: #{param.inspect})
43
45
  end
44
46
  index += 1
45
47
  }
@@ -4,6 +4,7 @@ require "thread"
4
4
  require "bytes"
5
5
  require "tds_types"
6
6
  require "tds_tokens"
7
+ require "thread"
7
8
 
8
9
  module Syspy
9
10
  class TdsPackageStream
@@ -15,7 +16,7 @@ module Syspy
15
16
  @interface = interface
16
17
  @dst = dst
17
18
  @dst_port = dst_port
18
- @in,@out = IO.pipe()
19
+ @packages = Queue.new()
19
20
  end
20
21
 
21
22
  def each_package()
@@ -28,8 +29,7 @@ module Syspy
28
29
 
29
30
  if(content.match(HEADER_REGEXP))
30
31
  payload = content[0..(-2 - HEADER_LENGTH)]
31
- @out.write(payload)
32
- @out.flush
32
+ @packages << payload
33
33
  content = ""
34
34
  end
35
35
 
@@ -39,19 +39,21 @@ module Syspy
39
39
  }
40
40
 
41
41
  content = ""
42
- @in.each_byte(){|byte|
42
+ loop(){
43
+ io = StringIO.new(@packages.shift)
44
+ byte = Bytes.uint(io)
43
45
  if(byte == 0x0F)
44
- last_packet_indicator = Bytes.uint(@in)
45
- length = Bytes.uint16be(@in)
46
+ last_packet_indicator = Bytes.uint(io)
47
+ length = Bytes.uint16be(io)
46
48
 
47
49
  # skip next 4 bytes of the header
48
- if(Bytes.uint32be(@in) == 0x00)
50
+ if(Bytes.uint32be(io) == 0x00)
49
51
  content << @in.read(length - 8)
50
52
 
51
53
  if(last_packet_indicator == 0x1)
52
54
  begin
53
- io = StringIO.new(content)
54
- package = handle_package(io)
55
+ content_io = StringIO.new(content)
56
+ package = handle_package(content_io)
55
57
  yield package if package
56
58
  ensure
57
59
  content = ""
@@ -20,8 +20,7 @@ module Syspy
20
20
  token = read_uint(io)
21
21
  if(token == TdsTokens::TDS_PARAMS)
22
22
  @tds_params = TdsParams.new(io,@tds_paramfmt)
23
- end
24
- end
23
+ end
25
24
  else
26
25
  Log.warn("Illegal paramfmt length: #{paramfmt_length}")
27
26
  end
@@ -23,13 +23,14 @@ module Syspy
23
23
 
24
24
  data_length = TdsTypes.fixed_length(data_type)
25
25
 
26
- if(data_length == -5)
27
- data_length = Bytes.int32le(io)
28
- elsif(data_length == -4)
29
- data_length = Bytes.int32le(io)
30
- elsif(data_length == -2)
31
- data_length = Bytes.int32le(io)
32
- elsif(data_length == -1)
26
+ case data_length
27
+ when -5
28
+ data_length = Bytes.int32le(io)
29
+ when -4
30
+ data_length = Bytes.int32le(io)
31
+ when -2
32
+ data_length = Bytes.int32le(io)
33
+ when data_length -1
33
34
  data_length = Bytes.uint(io)
34
35
  end
35
36
 
@@ -45,12 +45,13 @@ module Syspy
45
45
  TIME_DIFF = Time.at(0) - Time.local(1900,1,1)
46
46
 
47
47
  def read_datetime(io,data_type)
48
- if (data_type == TdsTypes::SYBDATETIMN)
49
- len = read_uint(io)
50
- elsif (data_type == TdsTypes::SYBDATETIME4)
51
- len = 4;
52
- else
53
- len = 8;
48
+ case data_type
49
+ when TdsTypes::SYBDATETIMN
50
+ len = read_uint(io)
51
+ when TdsTypes::SYBDATETIME4
52
+ len = 4;
53
+ else
54
+ len = 8;
54
55
  end
55
56
 
56
57
  #gmt_offset = Time.new().gmt_offset
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: syspy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.20
4
+ version: 0.0.21
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-14 00:00:00.000000000 Z
12
+ date: 2013-02-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bindata
16
- requirement: &20472460 !ruby/object:Gem::Requirement
16
+ requirement: &18848400 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *20472460
24
+ version_requirements: *18848400
25
25
  description:
26
26
  email: matthias.balmer@sysinf.ch
27
27
  executables: