#!/usr/local/bin/ruby
# Copyright (C) 2003  HIROSHIMA, Naoki  <naokih at iron-horse dot org>

def get_tai(tai)
  s = 0
  ns = 0
  tai.each_byte{|c|
    u = c.chr.hex
    s = s << 4
    s = s + (ns >> 28)
    s = s & 0xffffffff
    ns = ns & 0xfffffff
    ns = ns << 4
    ns = ns + u
  }
  s
end

#print get_tai("@4000003f57d65811f9fb6c");
now = Time.now.to_i
ok = 0
ng = 0

file = File.open('/service/tinydns/log/main/current')
while line = file.gets
  # @400000003f58ffe023c7eb74 d2ada506:08fe:9e26 + 0001 www.iron-horse.org
  info = line.split
  tai = get_tai(info[0])
  if (((now - 300) < tai) && (tai < now)) 
    if info[2] == '+' then
      ok += 1
    else
      ng += 1
    end
  end
end
file.close

print ok, "\n", ok+ng, "\n\n\n"
