I think this could be done easily with lite-c, or even better Pure c program.