#!/usr/bin/python

# This tool convert the input file in "id" format
# to the device.h format (to be compiled into IOS
# for verifying nvram content).
#   - The input file must be in the "id" format
#     where each line contains 32 bytes of ascii hex.
#     This is the file generated typically by the ID Creator.
#   - The output file device0.h will be generated.
#

import sys

lines = open(sys.argv[1]).readlines()

num = 0
last = 0

f = open("device%d.h" % num, "w")
f.write("u8 device[] = \n{");
line = {}
for line in lines:
  l = len(line)-1
  if (l > 10):
    for i in range(0, len(line)-1, 2):
      j = i + 1
      print i, j, len(line)-1, line[i], line[i+1]
      f.write("0x"+line[i]+line[i+1]+", ")
f.write("};\n");
f.close();

