#!/usr/bin/python

import os, sys
def fresh_serial(fn):
	fin = file(fn, 'r')
	lines = fin.readlines()
	fin.close()

	ols = []
	for line in lines:
		if line.find('__ZONE_SERIAL__') >= 0:
			curstr = line.split()[0]
			curo = line.find(curstr)
			newstr = '%-8d' % (int(curstr) + 1)
			oline = line[:curo] + newstr + line[curo + 8:]
			line = oline
			print 'zone %s: serial %s -> %d' % (fn, curstr, int(curstr) + 1)
		ols.append(line)
	
	fout = file(fn, 'w')
	fout.write(''.join(ols))
	fout.close()

if __name__ == '__main__':
	fresh_serial(sys.argv[1])
# vim:ts=2 sts=2 ai
