#!/opt/local/bin/ruby

require 'erb'

template = ERB.new <<-__TMPL__
typedef struct{
 const uint16_t attribute1;
 const uint32_t attribute2;
 const uint32_t attribute3;
}MYLIST;
static const MYLIST mylist[] =
{
<% elements.each do |attributes| %>
  {
  <%= attributes[0] %>
  <%= attributes[1] %>
  <%= attributes[2] %>
  },
<% end %>
}
__TMPL__

separator = ";"
inputfile = ARGV[0] or raise "missing input file"
elements  = Array.new

File.open(inputfile, "r") do |io|
  io.readlines.each do |line|
  	attributes = line.split(separator)
  	elements << attributes
  end
end

puts template.result(binding())
