syspy 0.0.21 → 0.0.22

Sign up to get free protection for your applications and to get access to all the features.
data/bin/syspy CHANGED
@@ -40,8 +40,10 @@ 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
+ elsif(param.nil?)
44
+ replaced_statement.gsub!(match,"NULL")
43
45
  else
44
- Log.warn(Non replacable parameter: #{match}: #{param.inspect})
46
+ Log.warn("Non replacable parameter: #{match}: #{param.inspect}")
45
47
  end
46
48
  index += 1
47
49
  }
@@ -4,7 +4,6 @@ require "thread"
4
4
  require "bytes"
5
5
  require "tds_types"
6
6
  require "tds_tokens"
7
- require "thread"
8
7
 
9
8
  module Syspy
10
9
  class TdsPackageStream
@@ -16,7 +15,7 @@ module Syspy
16
15
  @interface = interface
17
16
  @dst = dst
18
17
  @dst_port = dst_port
19
- @packages = Queue.new()
18
+ @in,@out = IO.pipe()
20
19
  end
21
20
 
22
21
  def each_package()
@@ -29,7 +28,8 @@ module Syspy
29
28
 
30
29
  if(content.match(HEADER_REGEXP))
31
30
  payload = content[0..(-2 - HEADER_LENGTH)]
32
- @packages << payload
31
+ @out.write(payload)
32
+ @out.flush
33
33
  content = ""
34
34
  end
35
35
 
@@ -39,21 +39,19 @@ module Syspy
39
39
  }
40
40
 
41
41
  content = ""
42
- loop(){
43
- io = StringIO.new(@packages.shift)
44
- byte = Bytes.uint(io)
42
+ @in.each_byte(){|byte|
45
43
  if(byte == 0x0F)
46
- last_packet_indicator = Bytes.uint(io)
47
- length = Bytes.uint16be(io)
44
+ last_packet_indicator = Bytes.uint(@in)
45
+ length = Bytes.uint16be(@in)
48
46
 
49
47
  # skip next 4 bytes of the header
50
- if(Bytes.uint32be(io) == 0x00)
48
+ if(Bytes.uint32be(@in) == 0x00)
51
49
  content << @in.read(length - 8)
52
50
 
53
51
  if(last_packet_indicator == 0x1)
54
52
  begin
55
- content_io = StringIO.new(content)
56
- package = handle_package(content_io)
53
+ io = StringIO.new(content)
54
+ package = handle_package(io)
57
55
  yield package if package
58
56
  ensure
59
57
  content = ""
@@ -15,12 +15,13 @@ module Syspy
15
15
  if(token == TdsTokens::TDS_PARAMFMT || token == TdsTokens::TDS_PARAMFMT2)
16
16
  paramfmt_length = Bytes.uintle(io,TdsTokens.length_field_size(token))
17
17
  if(paramfmt_length < 1000000)
18
- @tds_paramfmt = TdsTokens.token_class(token).new(io,paramfmt_length)
19
- if(@tds_paramfmt.params_count > 0)
20
- token = read_uint(io)
21
- if(token == TdsTokens::TDS_PARAMS)
22
- @tds_params = TdsParams.new(io,@tds_paramfmt)
23
- end
18
+ @tds_paramfmt = TdsTokens.token_class(token).new(io,paramfmt_length)
19
+ if(@tds_paramfmt.params_count > 0)
20
+ token = read_uint(io)
21
+ if(token == TdsTokens::TDS_PARAMS)
22
+ @tds_params = TdsParams.new(io,@tds_paramfmt)
23
+ end
24
+ end
24
25
  else
25
26
  Log.warn("Illegal paramfmt length: #{paramfmt_length}")
26
27
  end
@@ -30,8 +30,8 @@ module Syspy
30
30
  data_length = Bytes.int32le(io)
31
31
  when -2
32
32
  data_length = Bytes.int32le(io)
33
- when data_length -1
34
- data_length = Bytes.uint(io)
33
+ when -1
34
+ data_length = Bytes.uint(io)
35
35
  end
36
36
 
37
37
  parameter[:length] = data_length
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.21
4
+ version: 0.0.22
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2013-02-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bindata
16
- requirement: &18848400 !ruby/object:Gem::Requirement
16
+ requirement: &12546580 !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: *18848400
24
+ version_requirements: *12546580
25
25
  description:
26
26
  email: matthias.balmer@sysinf.ch
27
27
  executables: